You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We may add following methods to raise ParseError (or FindError?) and do not break backward compatibility:
selector.xpath_or_error # raises if query didn't match anything
selector.xpath_first # returns first, raises if query didn't match anything
selector.xpath_one # returns first, raises if query didn't match or return more than first element.
selector.css_* # same
or add parameter to xpath and css methods:
match=False # default, do not break backward compatibility
match=True # raise ParseError if selector didn't return anything
match=int # raise ParseError if returned elements length didn't matched
Consider this boilerplate code:
We may add following methods to raise ParseError (or FindError?) and do not break backward compatibility:
or add parameter to xpath and css methods:
I prefer ParseError name (because of "Parsel") and second option as it's easier to implement.
For first option you may see as example https://github.com/vgavro/requests-client/blob/master/requests_client/lxml.py
Please give me feedback so I may work on pull request, or how do you solve problem with early validation? Thank you.
The text was updated successfully, but these errors were encountered: