符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
目标:www.baidu.com
站在用户的角度思考问题,与客户深入沟通,找到衡阳县网站设计与衡阳县网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站制作、成都网站制作、企业官网、英文网站、手机端网站、网站推广、域名与空间、网站空间、企业邮箱。业务覆盖衡阳县地区。源码:
import requests url = 'http://www.baidu.com' header = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36' } free_proxy = { #都是http类型地址 ##'http': '163.204.241.160:9999' 'http': '123.206.54.52:8118' } response = requests.get(url=url, headers=header, proxies=free_proxy) print(response.status_code)使用代理'163.204.241.160:9999'出现
ProxyError:
Traceback (most recent call last): File "D:\Software\python3.7.4\lib\site-packages\urllib3\connection.py", line 160, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw) File "D:\Software\python3.7.4\lib\site-packages\urllib3\util\connection.py", line 80, in create_connection raise err File "D:\Software\python3.7.4\lib\site-packages\urllib3\util\connection.py", line 70, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\Software\python3.7.4\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen chunked=chunked) File "D:\Software\python3.7.4\lib\site-packages\urllib3\connectionpool.py", line 355, in _make_request conn.request(method, url, **httplib_request_kw) File "D:\Software\python3.7.4\lib\http\client.py", line 1244, in request self._send_request(method, url, body, headers, encode_chunked) File "D:\Software\python3.7.4\lib\http\client.py", line 1290, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "D:\Software\python3.7.4\lib\http\client.py", line 1239, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "D:\Software\python3.7.4\lib\http\client.py", line 1026, in _send_output self.send(msg) File "D:\Software\python3.7.4\lib\http\client.py", line 966, in send self.connect() File "D:\Software\python3.7.4\lib\site-packages\urllib3\connection.py", line 183, in connect conn = self._new_conn() File "D:\Software\python3.7.4\lib\site-packages\urllib3\connection.py", line 169, in _new_conn self, "Failed to establish a new connection: %s" % e) urllib3.exceptions.NewConnectionError:查过自己电脑网络配置中没有设置代理。
使用代理'123.206.54.52:8118'出现
ChunkedEncodingError:
Traceback (most recent call last): File "D:\Software\python3.7.4\lib\site-packages\urllib3\response.py", line 397, in _error_catcher yield File "D:\Software\python3.7.4\lib\site-packages\urllib3\response.py", line 479, in read data = self._fp.read(amt) File "D:\Software\python3.7.4\lib\http\client.py", line 457, in read n = self.readinto(b) File "D:\Software\python3.7.4\lib\http\client.py", line 501, in readinto n = self.fp.readinto(b) File "D:\Software\python3.7.4\lib\socket.py", line 589, in readinto return self._sock.recv_into(b) ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\Software\python3.7.4\lib\site-packages\requests\models.py", line 750, in generate for chunk in self.raw.stream(chunk_size, decode_content=True): File "D:\Software\python3.7.4\lib\site-packages\urllib3\response.py", line 531, in stream data = self.read(amt=amt, decode_content=decode_content) File "D:\Software\python3.7.4\lib\site-packages\urllib3\response.py", line 496, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "D:\Software\python3.7.4\lib\contextlib.py", line 130, in __exit__ self.gen.throw(type, value, traceback) File "D:\Software\python3.7.4\lib\site-packages\urllib3\response.py", line 415, in _error_catcher raise ProtocolError('Connection broken: %r' % e, e) urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None)", ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None)) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:/Study/工作/待解决问题/requests/requests_proxy.py", line 16, in推荐阅读:https://blog.csdn.net/wangzuxi/article/details/40377467
最后,将url = 'http://www.baidu.com' 改成 url = 'https://www.baidu.com', 使用以上两个代理地址测试都能成功,结果:200
-----
换了一个新的代理: 'http': '47.93.36.195:8118'
url = 'http://www.baidu.com'
多次运行,返回状态有200,503,还有ChunkedEncodingError
由此可见,ChunkedEncodingError错误并不是代理问题,为稳定,还是将url改为https为好。
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。