Search code examples
shellxqueryxidel

How to print values from different fields combined?


I'm using xidel and playing with web scraping (without templates for now). I would like to get the title and price of a book and its price so they could be printed on one line for each entry:

title --> price

Based on an answer from this forum I can write:

./xidel -e 'doc("https://books.toscrape.com")//*[self::p[@class="price_color"] or self::h3]'

But how to write title and its price in one line?

Thank you


Solution

  • Try

    ./xidel -e 'doc("https://books.toscrape.com")//article[@class = "product_pod"]!(.//h3 || "-->" || .//p[@class="price_color"])'