'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&quot;:&quot;BMW&quot;,&quot;Price&quot;:&quot;&#30000&quot;name&quot;:&quot;X5&quot;,&quot;color&quot;:null,&quot;}'>
</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_