How do I read a response from Python Requests?

前端 未结 3 769
天涯浪人
天涯浪人 2020-11-28 04:49

I have two Python scripts. One uses the Urllib2 library and one uses the Requests library.

I have found Requests easier to implement, but I can\'t find an equivalent

3条回答
  •  时光取名叫无心
    2020-11-28 05:39

    Requests doesn't have an equivalent to Urlib2's read().

    >>> import requests
    >>> response = requests.get("http://www.google.com")
    >>> print response.content
    '....'
    >>> print response.content == response.text
    True
    

    It looks like the POST request you are making is returning no content. Which is often the case with a POST request. Perhaps it set a cookie? The status code is telling you that the POST succeeded after all.

提交回复
热议问题