0
I have a scrapy running the for to bring the day and link to something. Ex:
t_day = div.xpath('.//a/text()').extract_first()
a_day = div.xpath('.//a/@href').extract_first()
day = int(t_day)
if day > last_day:
print(t_day, a_day)
And in execution returns the error:
in parse day = int(t_day) TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
What I need to do to solve the execution?
What is the content of the variable
t_day
?– Laerte
content executes values. xpath
– ChaarSales
I know, but what is the value that is assigned at the moment that it tries to parse the int(t_day), because the error that is giving is that the content is not numerical.
– Laerte
Ta going value Nonetype, I believe it is passing type Null same
– ChaarSales
You found the problem, null cannot be converted to integer.
– Laerte
how do I treat the comparison null for integer ?
– ChaarSales
You can leave a default value for it:
int(0 if a is None else t_day)
you can replace 0 by the value you want to be default.– Laerte
Thanks man, I executed here and it worked ! vlw
– ChaarSales