Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'geo' #297

Closed
treedom opened this issue Jul 29, 2023 · 1 comment
Closed

KeyError: 'geo' #297

treedom opened this issue Jul 29, 2023 · 1 comment

Comments

@treedom
Copy link

treedom commented Jul 29, 2023

2023-07-29 09:40:23 [scrapy.core.scraper] ERROR: Spider error processing <GET https://weibo.com/ajax/statuses/mymblog?uid=xxx&page=79> (referer: https://weibo.com/ajax/statuses/mymblog?uid=xxx&page=78)
return next(self.data)
File "/home/lighthouse/.local/lib/python3.10/site-packages/scrapy/utils/python.py", line 336, in next
for r in iterable:
File "/home/lighthouse/.local/lib/python3.10/site-packages/scrapy/spidermiddlewares/offsite.py", line 28, in
return (r for r in result or () if self._filter(r, spider))
File "/home/lighthouse/.local/lib/python3.10/site-packages/scrapy/core/spidermw.py", line 106, in process_sync
for r in iterable:
File "/home/lighthouse/.local/lib/python3.10/site-packages/scrapy/spidermiddlewares/referer.py", line 352, in
return (self._set_referer(r, response) for r in result or ())
File "/home/lighthouse/.local/lib/python3.10/site-packages/scrapy/core/spidermw.py", line 106, in process_sync
for r in iterable:
File "/home/lighthouse/.local/lib/python3.10/site-packages/scrapy/spidermiddlewares/urllength.py", line 27, in
return (r for r in result or () if self._filter(r, spider))
File "/home/lighthouse/.local/lib/python3.10/site-packages/scrapy/core/spidermw.py", line 106, in process_sync
for r in iterable:
File "/home/lighthouse/.local/lib/python3.10/site-packages/scrapy/spidermiddlewares/depth.py", line 31, in
return (r for r in result or () if self._filter(r, response, spider))
File "/home/lighthouse/.local/lib/python3.10/site-packages/scrapy/core/spidermw.py", line 106, in process_sync
for r in iterable:
File "/home/lighthouse/work/WeiboSpider/weibospider/spiders/tweet_by_user_id.py", line 38, in parse
item = parse_tweet_info(tweet)
File "/home/lighthouse/work/WeiboSpider/weibospider/spiders/common.py", line 94, in parse_tweet_info
"geo": data['geo'],
KeyError: 'geo'

image

谢谢作者小而美的工具,很好用。出现这个报错,有可能是有历史格式‘geo’ key并不存在?

@treedom
Copy link
Author

treedom commented Jul 30, 2023

can use .get(key[, default]) : "geo": data.get('geo', None)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant