Curso-lenguaje-python/python-ofensivo/08_librerias/03_requests_09_change_header.py

19 lines
382 B
Python
Raw Normal View History

2024-01-14 00:15:52 +01:00
#!/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)