Adding header to request using python requests module

0 votes
Hi. I want to send a header with my request to a web server using Python Requests module. You can I add the header to the request?
May 13, 2019 in Python by Reshma

1 answer to this question.

0 votes

You can use the headers option for that. Refer to the below code to do this:

>>> url = '<url>'
>>> headers = {'user-agent': 'my-app/0.0.1'}
>>> r = requests.get(url, headers=headers)
answered May 13, 2019 by Ishan

Related Questions In Python

0 votes
0 answers

how to add a header to a python request module?

can you give the syntax and an ...READ MORE

May 7, 2019 in Python by Waseem
• 4,540 points
0 votes
1 answer

Is it possible in Python requests to print entire HTTP request?

A better idea is to use the ...READ MORE

answered Nov 26, 2018 in Python by Nymeria
• 3,520 points
0 votes
1 answer
0 votes
1 answer

How to read photo using cv2 module in python?

Hi@akhtar, Yes, you can read your image in ...READ MORE

answered Apr 9 in Python by MD
• 53,860 points
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,344 views
0 votes
0 answers
+4 votes
6 answers
0 votes
1 answer

How to install Python MySQLdb module using pip?

It's easy to do, but hard to ...READ MORE

answered Aug 20, 2018 in Python by charlie_brown
• 7,780 points
0 votes
1 answer

How to pass query string in url using python requests?

You can pass the key-value pairs to ...READ MORE

answered May 13, 2019 in Python by Likith