'XPath one of multiple elements of an attribute
in this HTML using scrapy i can access the full info-car by : './/@info-car' XPath
<div class="car car-root"
info-car='{brand":"BMW","Price":"田"name":"X5","color":null,"}'>
</div>
what is the XPath to pick only the name of info-car ?
Solution 1:[1]
You can obtain the name by using a combination of xpath and regex. See below sample code:
response.xpath(".//@info-car").re_first(r'"name":"(.*)",')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | msenior_ |
