scrapy / parsel

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

Constructing selector with text argument raises if a numeric string is passed #281

Closed Nykakin closed 1 year ago

Nykakin commented 1 year ago

parsel.Selector can be initialized with a tagless string:

>>> from parsel import Selector
>>> 
>>> Selector(text="abc")
<Selector query=None data='<html><body><p>abc</p></body></html>'>

This raises if the value of the string is numeric:

>>> from parsel import Selector
>>> 
>>> Selector(text="12.3")
Traceback (most recent call last):
   ...
TypeError: object of type 'float' has no len()
Gallaecio commented 1 year ago

https://github.com/scrapy/parsel/issues/275