In [1]:
import requests
In [2]:
url = 'https://example.com/'
In [3]:
response = requests.get(url)
In [4]:
print(response)
In [5]:
print(type(response))
In [6]:
print(response.url)
In [7]:
print(response.status_code)
In [8]:
print(response.headers)
In [9]:
print(type(response.headers))
In [10]:
print(response.headers['Content-Type'])
In [11]:
print(response.headers['content-type'])
In [12]:
print(response.headers['cOntEnt-typE'])
In [13]:
# print(response.headers['xxxxx'])
# KeyError: 'xxxxx'
In [14]:
print(response.headers.get('xxxxx'))
In [15]:
print(response.encoding)
In [16]:
print(response.text)
In [17]:
print(type(response.text))
In [18]:
print(response.content)
In [19]:
print(type(response.content))
In [20]:
print(response.content.decode(response.encoding) == response.text)