[我正在使用Xpath用Python抓取网站,并希望在一个[]中返回多个元素
div class
我使用以下方法缩小了相关信息的范围
//*[@class='category-product js-productitem']
并且此选择位于Pastebin上:https://pastebin.com/0A6LQ9DC
我希望能够从这一选择中提取多个信息。例如,“数据产品编号”,“数据价格”,“数据特殊价格”等
我想了解如何表达与SQL等效的Xpath
SELECT data-productid, data-price, data-specialprice FROM category-product js-productitem
虽然了解Xpath,但绝对/相对路径使我有些困惑。我假设如果我以这种方式(而不是相对路径)引用标记/名称的[[unique组合,则可以通过Google Chromes的“检查”功能检查得到的信息,从而确保只获取期望的信息。
response.xpath('//*[@class='category-product js-productitem']/@data-productid').get()
response.xpath('//*[@class='category-product js-productitem']/@data-price').get()
response.xpath('//*[@class='category-product js-productitem']/@data-specialprice').get()