What is the difference between 'content' and 'text'
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Intrigue Looping
--
Chapters
00:00 What Is The Difference Between 'Content' And 'Text'
00:56 Accepted Answer Score 226
01:12 Answer 2 Score 15
01:29 Answer 3 Score 2
01:50 Thank you
--
Full question
https://stackoverflow.com/questions/1701...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pythonrequests
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Techno Intrigue Looping
--
Chapters
00:00 What Is The Difference Between 'Content' And 'Text'
00:56 Accepted Answer Score 226
01:12 Answer 2 Score 15
01:29 Answer 3 Score 2
01:50 Thank you
--
Full question
https://stackoverflow.com/questions/1701...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pythonrequests
#avk47
ACCEPTED ANSWER
Score 232
The requests.Response class documentation has more details:
r.text is the content of the response in Unicode, and r.content is the content of the response in bytes.
ANSWER 2
Score 15
It seems clear from the documentation is that r.content
You can also access the response body as bytes, for non-text requests:
>>> r.content
If you read further down the page it addresses for example an image file
ANSWER 3
Score 2
To some extent, text is nothing, but a sugar-coated version of content.
import requests
response = requests.get("https://httpbin.org/get")
response.text == response.content.decode(encoding == response.encoding)
True
All internet content is received in the form of bytes. Choose response.text for textual responses and use response.content for binary files like images or PDF