2 ms·
I'd use something like this script that you can put together yourself: #!/usr/bin/env ruby require 'nokogiri'; p Nokogiri::HTML(STDIN.read).css(ARGV[0]).te
by soheil 5y ago
I'd use something like this script that you can put together yourself:
#!/usr/bin/env ruby
require 'nokogiri'; p Nokogiri::HTML(STDIN.read).css(ARGV[0]).text
Just save it to a file in your /usr/local/bin/hq and do chmod +x !$
Then you can do:
curl -s "https://news.ycombinator.com/news"|hq "tr:first-child .storylink"
It uses Nokogiri[0], which is much more battle tested and works with CSS and XPath selectors.
[0] https://nokogiri.org/tutorials/parsing_an_html_xml_document.html#from-a-string https://nokogiri.org/tutorials/parsing_an_html_xml_document....
- drran 5y agoCommand just prints a bunch of text stitched together: curl -s "https://news.ycombinator.com/news"|hq "tr .storylink" Deploy a website on imgur.comMy £4 a month server can handle 4.2M requests a dayFirst Edition...