树莓派上的环境如下:
certifi-2018.8.24 chardet-3.0.4 idna-2.7 requests-2.19.1 urllib3-1.23
报错如下:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/urllib3/connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/usr/local/lib/python3.5/dist-packages/urllib3/util/connection.py", line 79, in create_connection
raise err
File "/usr/local/lib/python3.5/dist-packages/urllib3/util/connection.py", line 69, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.5/http/client.py", line 1107, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.5/http/client.py", line 1152, in _send_request
self.endheaders(body)
File "/usr/lib/python3.5/http/client.py", line 1103, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
self.send(msg)
File "/usr/lib/python3.5/http/client.py", line 877, in send
self.connect()
File "/usr/local/lib/python3.5/dist-packages/urllib3/connection.py", line 196, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.5/dist-packages/urllib3/connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7599ee30>: Failed to establish a new connection: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.5/dist-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='music.baidu.com', port=80): Max retries exceeded with url: /data/music/fmlink?songIds=315439071&type=flac (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7599ee30>: Failed to establish a new connection: [Errno 110] Connection timed out',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 163, in
main()
File "main.py", line 138, in main
d = get_song_info(songid)
File "main.py", line 87, in get_song_info
r = requests.get(BAIDU_MUSIC_API, params=payload)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 513, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='music.baidu.com', port=80): Max retries exceeded with url: /data/music/fmlink?songIds=315439071&type=flac (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7599ee30>: Failed to establish a new connection: [Errno 110] Connection timed out',))
PC上运行环境如下:
Python 3.7.0
Requirement already satisfied: requests in c:\users\51130\appdata\local\programs\python\python37\lib\site-packages (2.19.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\51130\appdata\local\programs\python\python37\lib\site-packages (from requests) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\51130\appdata\local\programs\python\python37\lib\site-packages (from requests) (2018.8.24)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in c:\users\51130\appdata\local\programs\python\python37\lib\site-packages (from requests) (1.23)
Requirement already satisfied: idna<2.8,>=2.5 in c:\users\51130\appdata\local\programs\python\python37\lib\site-packages (from requests) (2.7)
报错如下:
Traceback (most recent call last):
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
raise err
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1016, in _send_output
self.send(msg)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 956, in send
self.connect()
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 196, in connect
conn = self._new_conn()
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x0000024A26A6BBE0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 445, in send
timeout=timeout
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='sug.music.baidu.com', port=80): Max retries exceeded with url: /info/suggestion?word=%E6%B1%9F%E4%B8%8A%E6%B8%85%E9%A3%8E%E6%B8%B8&version=2&from=0 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000024A26A6BBE0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 163, in
main()
File "main.py", line 134, in main
songid = get_songid(value)
File "main.py", line 74, in get_songid
r = requests.get(BAIDU_SUGGESTION_API, params=payload)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "C:\Users\51130\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 513, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='sug.music.baidu.com', port=80): Max retries exceeded with url: /info/suggestion?word=%E6%B1%9F%E4%B8%8A%E6%B8%85%E9%A3%8E%E6%B8%B8&version=2&from=0 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000024A26A6BBE0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))