M
M
majorlazer14882020-06-02 16:00:13
css
majorlazer1488, 2020-06-02 16:00:13

How to output an attribute with a specific css or xpath word?

<img alt="Post image" class="_2_tDEnGMLxpM6uOa2kaDB3 ImageBox-image media-element _1XWObl-3b9tPy64oaG6fax" src="https://preview.redd.it/s57aenmpad251.jpg?width=640&amp;crop=smart&amp;auto=webp&amp;s=7ea456a9c2ee1c83c388de79fda7583bcf8571b5" style="max-height:512px">

I need to output all src attributes only if they start with https://preview, tried something like this but it outputs the entire img element
response.css('[src^="https://preview"]')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sundukov, 2020-06-02
@majorlazer1488

XPath:
//*[contains(@src, "preview.redd.it")]/@src

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question