dataabc / weibo-search

获取微博搜索结果信息,搜索即可以是微博关键词搜索,也可以是微博话题搜索
1.6k stars 361 forks source link

请问一运行就会有这个错误 #479

Open ArcherChloe opened 1 month ago

ArcherChloe commented 1 month ago

C:\Users\33721\Desktop\weibo-search-master>scrapy crawl search -s JOBDIR=crawls/search 2024-05-18 12:51:09 [scrapy.core.scraper] ERROR: Spider error processing <GET https://s.weibo.com/weibo?q=%23%E6%8A%91%E9%83%81%E7%97%87%23&scope=ori&suball=1&timescope=custom:2024-03-14-0:2024-03-15-0&page=1> (referer: https://s.weibo.com/weibo?q=%23%E6%8A%91%E9%83%81%E7%97%87%23&scope=ori&suball=1&timescope=custom:2024-03-01-0:2024-05-02-0) Traceback (most recent call last): File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\utils\defer.py", line 279, in iter_errback yield next(it) ^^^^^^^^ File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\utils\python.py", line 350, in next return next(self.data) ^^^^^^^^^^^^^^^ File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\utils\python.py", line 350, in next return next(self.data) ^^^^^^^^^^^^^^^ File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\core\spidermw.py", line 106, in process_sync for r in iterable: File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\spidermiddlewares\referer.py", line 352, in return (self._set_referer(r, response) for r in result or ()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\core\spidermw.py", line 106, in process_sync for r in iterable: File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\spidermiddlewares\urllength.py", line 27, in return (r for r in result or () if self._filter(r, spider)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\core\spidermw.py", line 106, in process_sync for r in iterable: File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\spidermiddlewares\depth.py", line 31, in return (r for r in result or () if self._filter(r, response, spider)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\33721\AppData\Local\Programs\Python\Python312\Lib\site-packages\scrapy\core\spidermw.py", line 106, in process_sync for r in iterable: File "C:\Users\33721\Desktop\weibo-search-master\weibo\spiders\search.py", line 153, in parse_by_day for weibo in self.parse_weibo(response): File "C:\Users\33721\Desktop\weibo-search-master\weibo\spiders\search.py", line 556, in parse_weibo print(weibo) ^^^^^ UnboundLocalError: cannot access local variable 'weibo' where it is not associated with a value 尝试改了一下但没有成功,请问一下怎么解决啊o(╥﹏╥)o

dataabc commented 1 month ago

感谢反馈。我现在不方便调试,您可以尝试修改search.py,把 avator = sel.xpath这行(大约在539行)及其之后的代码整体往后移动一个空格,看看有没有效果。

scarydemon2 commented 1 month ago

avator = sel.xpath

有效