Closed alfonsocheng1025 closed 4 years ago
说明你速度太快了,降低速度就可以了。具体修改get_follow_list方法:
if page - page1 == random_pages and page < page_num:
sleep(random.randint(6, 10))
page1 = page
random_pages = random.randint(1, 5)
上面是每爬1到5页,等待6到10秒,你可以加快等待频率或者增加等待时间。
说明你速度太快了,降低速度就可以了。具体修改get_follow_list方法:
if page - page1 == random_pages and page < page_num: sleep(random.randint(6, 10)) page1 = page random_pages = random.randint(1, 5)
上面是每爬1到5页,等待6到10秒,你可以加快等待频率或者增加等待时间。
感谢回复!这个问题已解决
你好,运行的时候出现以下errors: Error: 'NoneType' object has no attribute 'xpath' Traceback (most recent call last): File "D:\github_clone\weibo-follow\weibo_follow.py", line 132, in start self.get_follow_list() # 爬取微博信息 File "D:\github_clone\weibo-follow\weibo_follow.py", line 84, in get_follow_list page_num = self.get_page_num() File "D:\github_clone\weibo-follow\weibo_follow.py", line 58, in get_page_num if selector.xpath("//input[@name='mp']") == []: AttributeError: 'NoneType' object has no attribute 'xpath' 请问如何解决?谢谢!