'Multiple conditions when contains(@attribute) in Scrapy
For example, if I want to find link tag with application type "application/javascript" or "application/ecmascript", I would like to do something like this:
response.xpath("head/link[contains(@type, "javascript", "ecmascript")]")
It goes without saying that the code I putted above will raise an exception.
But I haven't found the way which will help me to apply multiple conditions in one XPath query.
Solution 1:[1]
Try this:
response.xpath("head/link[@type[contains(., 'javascript') or contains(., 'ecmascript')]]")
Be careful not using the same quotes in code and XPath.
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 | Siebe Jongebloed |
