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 in Python by Reshma
47 views

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 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 in Python by Waseem
• 4,470 points
15 views
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
245 views
0 votes
1 answer
+2 votes
2 answers

How to make a laplacian pyramid using OpenCV python?

down voteacceptTheeThe problem is that you're iterating ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,720 points
1,656 views
+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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 339 views
+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,720 points
94 views
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 in Python by Likith
31 views