Reputation: 1294
Sample code:
import requests
print requests.get("https://www.linkedin.com/")
I get: <Response [200]>
Simple curl request does work:
curl "https://www.linkedin.com/"
Upvotes: 0
Views: 200
Reputation: 146
The requests.get() function returns a Response object that contains attributes about the status_code, headers, and content:
[In]: type(requests.get("https://www.linkedin.com/")
[Out]: <class 'requests.models.Response'>
.
I would recommend saving the returned Response into a variable:
response = requests.get("https://www.linkedin.com/")
Then you can access the contents of the Response using response.json()
if it is a JSON file or response.text
if it is an html page.
In your use case, response.text
should return the same thing as curl "https://www.linkedin.com/"
.
Upvotes: 2
Reputation: 456
If you get <Response [200]>
that means that it worked properly. You should refer to the documentation for unpacking this Response
object to get the data inside of it.
E.g.:
>>> r = requests.get('https://linkedin.com/')
>>> r.text
'<!DOCTYPE html> ...'
Upvotes: 2