scrapy 对属性的多个元素之一进行XPath

de90aj5v  于 2022-11-09  发布在  其他
关注(0)|答案(1)|浏览(89)

在使用scrapy的HTML中,我可以通过以下方式访问完整的info-car'.//@info-car'路径路径

<div class="car car-root"
     info-car='{brand&quot;:&quot;BMW&quot;,&quot;Price&quot;:&quot;&#30000&quot;name&quot;:&quot;X5&quot;,&quot;color&quot;:null,&quot;}'>
</div>

只选择info-carname的XPath是什么?

92dk7w1h

92dk7w1h1#

您可以使用xpathregex的组合来取得名称。请参阅下列范例程式码:

response.xpath(".//@info-car").re_first(r'"name":"(.*)",')

相关问题