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

后端 未结 1 1893
一生所求
一生所求 2021-01-21 03:35
page = requests.get(url)
tree = html.fromstring(page.text)

At line 2 I get:

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


        
1条回答
  •  失恋的感觉
    2021-01-21 04:23

    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.

    0 讨论(0)
提交回复
热议问题