scrapy / parsel

Parsel lets you extract data from XML/HTML documents using XPath or CSS selectors
BSD 3-Clause "New" or "Revised" License
1.11k stars 137 forks source link

Support forcing a selector type into a subselector #299

Open Gallaecio opened 3 weeks ago

Gallaecio commented 3 weeks ago

Alternative to #298.

I’m not sure which one is the better approach, though.

But supporting this feature was part of one of the original iterations of JMESPath support, and it was removed at some point because we saw no use for it; it feels like this is a use case to justify its addition.

Fixes #297, resolves #298.

dream2333 commented 2 weeks ago

Great! This approach is also viable, but users might still adhere to their old habits of not adding a type parameter. In such cases, operations on text type nodes could still lead to some hard-to-trace issues. Should we consider making the Selector's type strongly typed, requiring a conversion to a usable type before performing queries, to avoid implicit type conversions?

Gallaecio commented 2 weeks ago

Should we consider making the Selector's type strongly typed, requiring a conversion to a usable type before performing queries, to avoid implicit type conversions?

Sounds interesting, could you elaborate? What user-facing API do you have in mind, how would it compare to passing the parameter?