dataabc / weibo-search

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

小白求问,TypeError: expected string or bytes-like object 这是什么意思 #192

Open ajingjing145 opened 2 years ago

ajingjing145 commented 2 years ago

运行之后出现这个 D:\python work\weibo-search-master>scrapy crawl search 2022-04-17 20:17:15 [scrapy.core.scraper] ERROR: Spider error processing <GET https://s.weibo.com/weibo?q=%E4%B8%8A%E6%B5%B7%E7%96%AB%E6%83%85&typeall=1&suball=1&timescope=custom:2022-04-15-10:2022-04-15-11&page=1> (referer: https://s.weibo.com/weibo?q=%E4%B8%8A%E6%B5%B7%E7%96%AB%E6%83%85&typeall=1&suball=1&timescope=custom:2022-04-15-0:2022-04-16-0&page=1) Traceback (most recent call last): File "D:\anaconda\lib\site-packages\scrapy\utils\defer.py", line 132, in iter_errback yield next(it) File "D:\anaconda\lib\site-packages\scrapy\utils\python.py", line 354, in next return next(self.data) File "D:\anaconda\lib\site-packages\scrapy\utils\python.py", line 354, in next return next(self.data) File "D:\anaconda\lib\site-packages\scrapy\core\spidermw.py", line 66, in _evaluate_iterable for r in iterable: File "D:\anaconda\lib\site-packages\scrapy\spidermiddlewares\offsite.py", line 29, in process_spider_output for x in result: File "D:\anaconda\lib\site-packages\scrapy\core\spidermw.py", line 66, in _evaluate_iterable for r in iterable: File "D:\anaconda\lib\site-packages\scrapy\spidermiddlewares\referer.py", line 342, in return (_set_referer(r) for r in result or ()) File "D:\anaconda\lib\site-packages\scrapy\core\spidermw.py", line 66, in _evaluate_iterable for r in iterable: File "D:\anaconda\lib\site-packages\scrapy\spidermiddlewares\urllength.py", line 40, in return (r for r in result or () if _filter(r)) File "D:\anaconda\lib\site-packages\scrapy\core\spidermw.py", line 66, in _evaluate_iterable for r in iterable: File "D:\anaconda\lib\site-packages\scrapy\spidermiddlewares\depth.py", line 58, in return (r for r in result or () if _filter(r)) File "D:\anaconda\lib\site-packages\scrapy\core\spidermw.py", line 66, in _evaluate_iterable for r in iterable: File "D:\python work\weibo-search-master\weibo\spiders\search.py", line 198, in parse_by_hour for weibo in self.parse_weibo(response): File "D:\python work\weibo-search-master\weibo\spiders\search.py", line 425, in parse_weibo attitudes_count = re.findall(r'\d+.*', attitudes_count) File "D:\anaconda\lib\re.py", line 241, in findall return _compile(pattern, flags).findall(string) TypeError: expected string or bytes-like object

dataabc commented 2 years ago

貌似没有得到数据,不知道是不是cookie不正确。

ajingjing145 commented 2 years ago

更新了cookie就好了,谢谢!

yxxy0721 commented 2 years ago

我和你的问题一样,cookie更新了也没用 该如何解决呢

dataabc commented 2 years ago

@yxxy0721 之前有成功过吗?可能还是cookie不正确。

yxxy0721 commented 2 years ago

没有成功过,一直是这个问题

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Chen Lei @.> 发送时间: 2022年4月20日 23:43 收件人: dataabc/weibo-search @.> 抄送: yxxy0721 @.>, Mention @.> 主题: Re: [dataabc/weibo-search] 小白求问,TypeError: expected string or bytes-like object 这是什么意思 (Issue #192)

@yxxy0721 之前有成功过吗?可能还是cookie不正确。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

dataabc commented 2 years ago

@yxxy0721 可能是cookie的原因或者账号被限制了,你可以在我的weiboSpider程序上看看,是否能成功,成功了cookie就没问题。

yxxy0721 commented 2 years ago

同样的cookie spider就没问题

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Chen Lei @.> 发送时间: 2022年4月21日 23:25 收件人: dataabc/weibo-search @.> 抄送: yxxy0721 @.>, Mention @.> 主题: Re: [dataabc/weibo-search] 小白求问,TypeError: expected string or bytes-like object 这是什么意思 (Issue #192)

@yxxy0721 可能是cookie的原因或者账号被限制了,你可以在我的weiboSpider程序上看看,是否能成功,成功了cookie就没问题。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

dataabc commented 2 years ago

@yxxy0721 是不是修改settings.py文件的COOKIES_ENABLED了?

yxxy0721 commented 2 years ago

是滴

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Chen Lei @.> 发送时间: 2022年4月21日 23:49 收件人: dataabc/weibo-search @.> 抄送: yxxy0721 @.>, Mention @.> 主题: Re: [dataabc/weibo-search] 小白求问,TypeError: expected string or bytes-like object 这是什么意思 (Issue #192)

@yxxy0721 是不是修改settings.py文件的COOKIES_ENABLED了?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

dataabc commented 2 years ago

@yxxy0721 @ajingjing145 COOKIES_ENABLED保持默认值,不要修改

yxxy0721 commented 2 years ago

感谢 我明天去看看

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: Chen Lei @.> 发送时间: 2022年4月21日 23:51 收件人: dataabc/weibo-search @.> 抄送: yxxy0721 @.>, Mention @.> 主题: Re: [dataabc/weibo-search] 小白求问,TypeError: expected string or bytes-like object 这是什么意思 (Issue #192)

@yxxy0721 @ajingjing145 COOKIES_ENABLED保持默认值,不要修改

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

Lholy-in commented 2 years ago

我也遇到这个问题了,然后我把每个re.findall(r'\d+.',attitudes_count)都改成了re.findall(r'\d+.', str(attitudes_count))就解决了。

Lxiaobu commented 2 years ago

我也遇到这个问题了,然后我把每个re.findall(r'\d+._',attitudescount)都改成了re.findall(r'\d+.', str(attitudes_count))就解决了。

这是那个文件的代码? 前面的方法我都试过了 还是这样子

Lholy-in commented 2 years ago

search.py里面的,所有类似于re.findall(r'\d+.',XXX)的改成了re.findall(r'\d+.',str(XXX)。 (然后程序就不报错了,我也不知道为啥(●—●))

---原始邮件--- 发件人: @.> 发送时间: 2022年4月22日(周五) 晚上10:59 收件人: @.>; 抄送: @.**@.>; 主题: Re: [dataabc/weibo-search] 小白求问,TypeError: expected string or bytes-like object 这是什么意思 (Issue #192)

我也遇到这个问题了,然后我把每个re.findall(r'\d+.',attitudes_count)都改成了re.findall(r'\d+.', str(attitudes_count))就解决了。

这是那个文件的代码? 前面的方法我都试过了 还是这样子

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Lxiaobu commented 2 years ago

查到了 https://blog.csdn.net/K_Lily/article/details/105563869

luolovehk commented 2 years ago

search.py里面的,所有类似于re.findall(r'\d+.',XXX)的改成了re.findall(r'\d+.',str(XXX)。 (然后程序就不报错了,我也不知道为啥(●—●)) ---原始邮件--- 发件人: @.> 发送时间: 2022年4月22日(周五) 晚上10:59 收件人: @.>; 抄送: @.**@.>; 主题: Re: [dataabc/weibo-search] 小白求问,TypeError: expected string or bytes-like object 这是什么意思 (Issue #192) 我也遇到这个问题了,然后我把每个re.findall(r'\d+.',attitudes_count)都改成了re.findall(r'\d+.', str(attitudes_count))就解决了。 这是那个文件的代码? 前面的方法我都试过了 还是这样子 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

大佬厉害,我按照这个改成功了