简体   繁体   English

Scrapy 无法使用 Xpath 检索属性值

[英]Scrapy unable to retirve attribute value using Xpath

I am trying to get hold of the @src attribute using xPath but when I ran my scrapy it returns an empty array.我正在尝试使用 xPath 获取@src属性,但是当我运行我的 scrapy 时,它返回一个空数组。 Someone please explain to me where did I do wrong?有人请向我解释我做错了什么?

Snippet of the HTML code with the attribute带有属性的 HTML 代码片段

xPath //div[@class='BuC9jaLeEj']//child::div/img[@class='P2llUzsDMi']/@src xPath //div[@class='BuC9jaLeEj']//child::div/img[@class='P2llUzsDMi']/@src

Using the browser I am able to locate the path to the tag name but when I run my Scrapy bot it return an empty array.使用浏览器,我可以找到标签名称的路径,但是当我运行 Scrapy 机器人时,它返回一个空数组。

You might also find this useful:您可能还会发现这很有用:

You can then pick out the image from the dictionary然后您可以从字典中挑选图像

https://pypi.org/project/chompjs/ https://pypi.org/project/chompjs/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM