I'm using the Python requests library. I'm trying to figure out how to extract the actual HTML body from a response. The code looks a bit like this:
r = requests.get(...) print r.content
This should indeed print lots of content, but instead prints nothing.
Any suggestions? Maybe I've misunderstood how requests.get() works?
Simple use requests. get() method to get all body content and use response. json() to get JSON data.
Method Summary Peeks into the JSON that JsonPath will parse by printing it to the console. Peeks into the response body by printing it to the console in a prettified manner. Pretty-print the response body if possible and return it as string. Print the response body and return it as string.
Your code is correct. I tested:
r = requests.get("http://www.google.com") print(r.content)
And it returned plenty of content. Check the url, try "http://www.google.com". Cheers!
import requests site_request = requests.get("https://abhiunix.in") site_response = str(site_request.content) print(site_response)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With