dataabc / weibo-search

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

大佬你好,请问之前可以正常运行,现在运行报错:TypeError: expected string or bytes-like object,要怎么处理? #225

Open liliners opened 2 years ago

liliners commented 2 years ago

搜狗截图20220610101103 (venv) PS C:\Users\lilin\Desktop\weiboyuqing\weiboyuqing\pachong\pachong\weibo-search\weibo\spiders> scrapy crawl search 2022-06-10 10:06:40 [scrapy.core.scraper] ERROR: Spider error processing <GET https://s.weibo.com/weibo?q=%23%E6%96%B0%E5%86%A0%E8%82%BA%E7%82%8E%23&scope=ori&suball=1&timescope=custom :2022-05-01-0:2022-05-09-0&display=0&retcode=6102> (referer: None) Traceback (most recent call last): File "C:\Users\lilin\Desktop\weiboyuqing\weiboyuqing\venv\lib\site-packages\scrapy\utils\defer.py", line 132, in iter_errback yield next(it) File "C:\Users\lilin\Desktop\weiboyuqing\weiboyuqing\venv\lib\site-packages\scrapy\utils\python.py", line 354, in next return next(self.data) File "C:\Users\lilin\Desktop\weiboyuqing\weiboyuqing\venv\lib\site-packages\scrapy\utils\python.py", line 354, in next return next(self.data) File "C:\Users\lilin\Desktop\weiboyuqing\weiboyuqing\venv\lib\site-packages\scrapy\core\spidermw.py", line 66, in _evaluate_iterable for r in iterable: File "C:\Users\lilin\Desktop\weiboyuqing\weiboyuqing\venv\lib\site-packages\scrapy\spidermiddlewares\offsite.py", line 29, in process_spider_output File "C:\Users\lilin\Desktop\weiboyuqing\weiboyuqing\pachong\pachong\weibo-search\weibo\spiders\search.py", line 107, in parse for weibo in self.parse_weibo(response): File "C:\Users\lilin\Desktop\weiboyuqing\weiboyuqing\pachong\pachong\weibo-search\weibo\spiders\search.py", line 420, in parse_weibo comments_count = re.findall(r'\d+.*', comments_count) File "D:\Python\lib\re.py", line 239, in findall return _compile(pattern, flags).findall(string) TypeError: expected string or bytes-like object

liliners commented 2 years ago

已经解决了,估计是没注意改动到哪里了

fyfyfyfy11 commented 2 years ago

我也是遇到了同样的问题

fyfyfyfy11 commented 2 years ago

如何修改呢

liliners commented 2 years ago

我把每个re.findall(r'\d+.',attitudes_count)都改成了re.findall(r'\d+.', str(attitudes_count))就解决了。

liliners commented 2 years ago

image

fyfyfyfy11 commented 2 years ago

THANKS!

DeNancy commented 2 years ago

我把每个re.findall(r'\d+.',attitudes_count)都改成了re.findall(r'\d+.', str(attitudes_count))就解决了。

感谢,问题解决了