0

I am unable to remove default headers sent by Python requests.

These are the default headers which python requests is sending:

User-Agent: python-requests/2.24.0
Accept-Encoding: gzip, deflate
Accept: application/json
Connection: keep-alive

here is my code:

    import requests

url = ('http://google.com')
headers = {
    'Accept': 'application/json',
    'Host': 'google.com'
    }
for num_of_res in range(1,10):
    print(num_of_res)
response = requests.get((url.format(num_of_res)), headers=headers, verify= False)
6
  • 2
    Does this answer your question? Sending "User-agent" using Requests library in Python Commented Aug 31, 2020 at 9:52
  • @ThePjot No. I only want to send 'Accept and Host' in headers Commented Aug 31, 2020 at 9:56
  • Yes, and you have to override user-agent if you want to get rid of it :) Commented Aug 31, 2020 at 10:02
  • Like How? I can set user-agent value to none, but its still sending "user-agent : none" instead of removing user-agent field Commented Aug 31, 2020 at 10:05
  • Perhaps setting it to a empty string? Why wouldn't you want a user-agent to begin with really? Just put some jibberish or fake in it if so desired. Commented Aug 31, 2020 at 10:16

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.