【发布时间】:2020-10-19 02:24:20
【问题描述】:
我正在尝试使用 Python 的请求库发出 Get 请求。我可以很好地运行快速入门示例,但是当我更改 URL 时,代码很长时间没有返回,最后返回了一些错误,这些错误引用了请求库代码中的深层代码。我一直在尝试用谷歌搜索,但这超出了我初学者的理解范围。传递给 requests.get() 的 URL 的语法是否有一些限制?以下是 URL 无效的代码:
import requests
URL = 'https://www.landsofamerica.com/United-States/lakefront-property/'
r = requests.get(URL)
print(r.text)
"""
NOTE: This code taken from https://requests.readthedocs.io/en/master/user/quickstart/#make-a-request
The example code in the docs *does* execute correctly with this example URL:
URL = 'https://api.github.com/events'
"""
返回的错误很长,我不知道如何找到“最相关的部分”来寻求帮助,所以我认为我不应该把这些都粘贴在这里?谢谢。
【问题讨论】:
标签: get python-requests