使用python请求库

时间:2018-03-14 19:30:06

标签: python-requests

您好

我正在尝试使用python“requests”库访问Web数据。以下是使用错误消息执行的代码的详细信息。感谢您解决此问题的任何帮助。

python版本:3.5.2 | Anaconda 4.2.0(32位)| (默认,2016年7月5日,11:45:57)[MSC v.1900 32位(英特尔)]

逻辑:

import requests
response = requests.get("http://dataquestio.github.io/web-scraping-pages/simple.html")
response.text

回溯

---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)

ConnectionError: HTTPConnectionPool(host='dataquestio.github.io', port=80): Max retries exceeded with url: /web-scraping-pages/simple.html (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x03E676B0>: 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',))

谢谢, 戈帕尔

1 个答案:

答案 0 :(得分:0)

我运行了您上面提供的代码,并获得了以下内容output: