Python, mechanize, proper syntax for setting multiple headers?

后端 未结 1 713
梦谈多话
梦谈多话 2020-12-18 00:55

I can\'t seem to find how to do this anywere, I am trying to set multiple headers with python\'s mechanize module, such as:

br.addheaders = [(\'user-agent\',         


        
相关标签:
1条回答
  • 2020-12-18 01:20

    According to http://wwwsearch.sourceforge.net/mechanize/doc.html#adding-headers, the syntax would be

    br.addheaders = [('user-agent', '   Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3'),
    ('accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')]
    

    That is, make a list of header tuples.

    0 讨论(0)
提交回复
热议问题