Last modified: Jan 10, 2023 By Alexander Williams
How to Set Headers Post Requests in python
in this tutorial, we'll learn how to set Headers with python Requests' library
instaling the requests library
$ pip install requests
Request Headers
response = requests.get(
'https://api.github.com/search/repositories',
params={'q': 'requests+language:python'},
headers={'Accept': 'application/vnd.github.v3.text-match+json'},
)
# View the new `text-matches` array which provides information
# about your search term within the results
json_response = response.json()
repository = json_response['items'][0]
print(f'Text matches: {repository["text_matches"]}')