1

I am working on a project that requires web scraping. Hence I was looking at the Requests library in Python. In the quickstart page of the library the following code example is given:

>>> import requests
>>> r = requests.get('https://github.com/timeline.json')
>>> r.text
'[{"repository":{"open_issues":0,"url":"https://github.com/...

On trying out that code I found that the following error is returned when I try to print r.text:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Response' object has no attribute 'text'

What am I doing wrong?

4

1 に答える 1

1

試してみてくださいr.content- 古いバージョンのリクエストまたはアップグレードで動作するはずです。python 2.7使用中のリクエストをアップグレードするにはsudo pip-2.7 install requests --upgrade

于 2013-02-06T08:25:23.560 に答える