Open nramirezuy opened 8 years ago
I think this can be implemented in two different methods one returning text and the other returning the actual Selector
instances.
What about this?
uri()
, which returns the first URI found in a selector or selector list, as a string, resolved to absolute URIs when possible.uris()
, which iterates through all the URIs found in a selector or selector list, as strings, resolved to absolute URIs when possible.uri()
and uris()
to extract resolved URIs from arbitrary element strings and attributes, including custom data-*
attributes.xpath
or css
beforehand, pointing to the desired attributes.xpath
or css
beforehand.As for a version that returns Selector
instances, what’s the use case? Maybe providing some predefined, importable XPath expressions (e.g. from parsel.xpath import URI_XPATH
) would be a better approach.
This was originally on Scrapy. Moving it to Parsel to continue discussion.
https://github.com/scrapy/scrapy/pull/331