TA的每日心情 | 开心 2020-12-29 09:50 |
---|
签到天数: 165 天 [LV.7]常住居民III
解元
- 积分
- 1807
|
本帖最后由 Husigh 于 2017-11-16 11:05 编辑
b大脚本名为******.py。eb的账号已经找到了,现在是速度特别慢,老是报错。错误信息如下。py是2.7.14版
eb机构账户是不是可以开多窗口?如何设置分块多窗口提取?请教各位,谢谢。
-Traceback (most recent call last):
File "D:\M\******.py", line 244, in __fetchdata_and_make_mdx
page = self.postdata(start, pos)
File "D:\M\******.py", line 526, in postdata
r = self.__session.post(self.__base_url, data=param, timeout=100)
File "C:\Python27\lib\requests\sessions.py", line 555, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "C:\Python27\lib\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\requests\sessions.py", line 658, in send
r.content
File "C:\Python27\lib\requests\models.py", line 823, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "C:\Python27\lib\requests\models.py", line 752, in generate
raise ConnectionError(e)
ConnectionError: HTTPConnectionPool(host='**.***.com', port=80): Read timed out.
None
'180: 9' failed, retry automatically later
- Traceback (most recent call last):
File "D:\M\******.py", line 247, in __fetchdata_and_make_mdx
word = self.makeword(page, words, pic)
File "D:\M\******.py", line 595, in makeword
worddef = p.sub(lambda m: self.__chgimg(m, pic), worddef)
File "D:\M\******.py", line 595, in <lambda>
worddef = p.sub(lambda m: self.__chgimg(m, pic), worddef)
File "D:\M\******.py", line 572, in __chgimg
div = p.sub(lambda n: self.__repimg(m.group(1), n.group(1), self.__origin), div)
File "D:\M\******.py", line 572, in <lambda>
div = p.sub(lambda n: self.__repimg(m.group(1), n.group(1), self.__origin), div)
File "D:\M\******.py", line 547, in __repimg
dump(self.getpage(''.join([rpath, fnm]), base_url), file, 'wb')
File "D:\M\******.py", line 522, in getpage
return getpage(self.__session, link, base_url)
File "D:\M\******.py", line 73, in getpage
r = session.get(url, timeout=10, allow_redirects=False)
File "C:\Python27\lib\requests\sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "C:\Python27\lib\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\requests\sessions.py", line 658, in send
r.content
File "C:\Python27\lib\requests\models.py", line 823, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "C:\Python27\lib\requests\models.py", line 752, in generate
raise ConnectionError(e)
ConnectionError: HTTPConnectionPool(host='**.***', port=80): Max retries exceeded
with url: /baidu/%2A (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000000000386BE80>: Failed to establish a new connection: [Errno 10060] ',))
File "C:\Python27\lib\requests\adapters.py", line 508, in send
raise ConnectionError(e, request=request)
有找过解决办法不知从何下手
例:http连接太多没有关闭导致的
1、增加重试连接次数
requests.adapters.DEFAULT_RETRIES = 5
2、关闭多余的连接
requests使用了urllib3库,默认的http connection是keep-alive的,requests设置False关闭。
操作方法
s = requests.session()
s.keep_alive = False
|
|