'I have a problem with this scrapy script to export data from a site
I have a problem with this scrapy script to export data from a site. It used to work now when I launch it it gives me an error that I don't understand
2022-03-02 15:52:10 [scrapy.core.scraper] ERROR: Spider error processing <GET https://sofifa.com/player/158023?units=mks/> (referer: None)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/utils/defer.py", line 120, in iter_errback
yield next(it)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/utils/python.py", line 353, in __next__
return next(self.data)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/utils/python.py", line 353, in __next__
return next(self.data)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/core/spidermw.py", line 56, in _evaluate_iterable
for r in iterable:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/spidermiddlewares/offsite.py", line 29, in process_spider_output
for x in result:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/core/spidermw.py", line 56, in _evaluate_iterable
for r in iterable:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/spidermiddlewares/referer.py", line 342, in <genexpr>
return (_set_referer(r) for r in result or ())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/core/spidermw.py", line 56, in _evaluate_iterable
for r in iterable:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/spidermiddlewares/urllength.py", line 40, in <genexpr>
return (r for r in result or () if _filter(r))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/core/spidermw.py", line 56, in _evaluate_iterable
for r in iterable:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/spidermiddlewares/depth.py", line 58, in <genexpr>
return (r for r in result or () if _filter(r))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/scrapy/core/spidermw.py", line 56, in _evaluate_iterable
for r in iterable:
File "/Users/trivius86/Documents/fifa-stats-crawler-master/fifa_crawler/fifa_parser/spiders/players_stats.py", line 89, in parse
age, month, day, year, height, weight = player_info[0].split()
IndexError: list index out of range
Solution 1:[1]
It's likely that your are getting None type values from player_info under some instances, and so you cannot index a None value. Therefore, you're getting thrown the following error:
IndexError: list index out of range
To proceed, you might want to instantiate your code within an if-statement, something like:
if player_info != None:
age, month, day, year, height, weight = player_info[0].split()
else:
pass
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Emil11 |
