Custom Scripting Python Scripts

I saw this post about sending asynchronous requests using grequests.

import grequests urls = [ 'http://www.heroku.com', 'http://tablib.org', 'http://httpbin.org', 'http://python-requests.org', 'http://kennethreitz.com' ] rs = (grequests.get(u) for u in urls) grequests.map(rs) 

Say, for just one URL, I wanted to send a custom header:

 header = {'authorization' : '...'} 

How can I send a custom header for a single url using grequests?

+6
source share
1 answer

You simply include the header in arguments like your .get () requests.

 header = {'authorization' : '...'} rs = (grequests.get(u, headers=header) for u in urls) grequests.map(rs) 
+7
source

Source: https://habr.com/ru/post/950097/


All Articles