0

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/"
NeDark
  • 1,212
  • 7
  • 23
  • 36

2 Answers2

2

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> ...'
K. Dackow
  • 456
  • 1
  • 3
  • 15
2

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/".

Yang T
  • 146
  • 5