使用请求获取内容网页

Maz*_*zzy 2 python get python-requests

我正在尝试使用以下方法获取 html 网页的内容

r = requests.get(url-page)

r.text()
Run Code Online (Sandbox Code Playgroud)

我想取回整个 html 页面,但不幸的是我收到以下错误

TypeError: 'unicode' object is not callable
Run Code Online (Sandbox Code Playgroud)

Jam*_*lls 5

.text只是Response对象的一个属性。

例子:

>>> from requests import get
>>> response = get("http://www.google.com")
>>> response.text[:9]
u'<!doctype'
>>>
Run Code Online (Sandbox Code Playgroud)

如果它是一个属性,就像任何普通的对象属性访问一样,您不必“调用”该属性。

请参阅:有关响应内容的请求文档