Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'Response' object has no attribute 'text'

page = requests.get(url)
tree = html.fromstring(page.text)

At line 2 I get:

AttributeError: 'Response' object has no attribute 'text'

I have imported requests and installed requests. How do I debug this error? can anyone tell command to install lastest requests module?

like image 738
user3438081 Avatar asked Mar 27 '14 13:03

user3438081


1 Answers

You are using an ancient version of requests, most likely because it came installed with Ubuntu Precise Pengolin (12.04LTS).

You'll either have to refer to the version specific documentation or use a more recent version. requests has changed drastically since the 0.x version days.

For your old version, if you set response.encoding, response.content will contain a decoded Unicode value.

like image 155
Martijn Pieters Avatar answered Nov 07 '22 04:11

Martijn Pieters