You've already forked Curso-lenguaje-python
Update requests exercise
This commit is contained in:
18
python-ofensivo/08_librerias/03_requests_09_change_header.py
Normal file
18
python-ofensivo/08_librerias/03_requests_09_change_header.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from requests import Request, Session
|
||||
|
||||
url = 'https://httpbin.org/get'
|
||||
s = Session()
|
||||
|
||||
headers = {'Custom-Header':'my_custom_header'}
|
||||
|
||||
req = Request('GET', url, headers=headers)
|
||||
|
||||
prepped = req.prepare()
|
||||
|
||||
prepped.headers['Custom-Header'] = 'my_header_changed'
|
||||
prepped.headers['Another-Header'] = 'other_header'
|
||||
response = s.send(prepped)
|
||||
|
||||
print(response.text)
|
||||
Reference in New Issue
Block a user