当前位置 : 主页 > 编程语言 > python >

Error (ProtocolError(‘Connection aborted.‘, RemoteDisconnected(‘Remote end closed connection wi

来源:互联网 收集:自由互联 发布时间:2022-06-15
我本来在爬取weibo,于是就给我报错了如下: Error ( ProtocolError ( 'Connection aborted.' , RemoteDisconnected ( 'Remote end closed connection without response' )),) 解决办法: user_agent_list = [ "Mozilla/5.0 (Windows

我本来在爬取weibo,于是就给我报错了如下:

Error (ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')),)

解决办法:

user_agent_list = [
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/61.0",
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36",
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36",
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)",
"Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15",
]
headers={
'User-Agent':random.choice(user_agent_list)
}


上一篇:爬虫学习(16):CSV文件存储
下一篇:没有了
网友评论