Xq - Command-line XPath Processor For HTML And XML - GitHub

xq

xq is a lightweight command-line XPath processor for HTML and XML.

Build Status

Usage

Extracting simple content from HTML with XPath:

curl -s https://news.ycombinator.com/ | ./xq "//title" #=> Hacker News

Extracting content from XML with XPath:

curl -s http://w1.weather.gov/xml/current_obs/KBOS.xml | ./xq "//current_observation/temp_f" # => 59.0

A bit more sophisticated XPath from standard input:

cat ./data/wiki_page.html | ./xq "//table[@class='multicol'][7]//a/@href" #=> #... #/wiki/Go_(programming_language) #...

Development

go get -u github.com/otobrglez/xq sudo apt-get install libxml2-dev make test

Details

  • Project was inspired by jq - Command-line JSON processor
  • Project uses gokogiri and libxml2.

License & Author

Oto Brglez - MIT License.

Từ khóa » Xq Github