【发布时间】:2020-03-11 23:29:15
【问题描述】:
我正在使用 Xpath 使用 Python 抓取网站,并希望在
中返回多个元素div class
我已使用
缩小了相关信息的范围//*[@class='category-product js-productitem']
这个选择在 Pastebin 上:https://pastebin.com/0A6LQ9DC
我希望能够从这一选择中提取多位信息。例如,“data-productid”、“data-price”、“data-specialprice”等
我想了解如何表示 Xpath 等价于 SQL
SELECT data-productid, data-price, data-specialprice FROM category-product js-productitem
在学习 Xpath 的同时,绝对/相对路径让我有些困惑。我假设如果我以这种方式(而不是相对路径)引用标签/名称的 唯一组合,我可以确保只获得我期望的信息,通过 Google Chrome 'inspect '函数。
【问题讨论】:
标签: python xml xpath screen-scraping