Is there any Python HTTP library that helps to imitate one of popular web-browser and has HTTPS support? I would like to define the order of HTTP headers, the presence of each exact header, the order of cookies values - everything that relates to "fingerprint" of a browser. We need that to test specific web server.
问问题
403 次
2 回答
2
httplib.request
将需要一个OrderedDict
for 标题。某些标头将自动添加以符合协议,如果您在提供的标头中指定它们,这些标头将被忽略。
查看putheader
and_send_request
方法,如果它们的行为不符合您的目的,您可以覆盖它们。
>>> import httplib
>>> from collections import OrderedDict
>>> h = OrderedDict(('X-A','a'),('X-B','b'),('X-C','c'))
>>> c = httplib.HTTPConnection('localhost')
>>> c.set_debuglevel(1)
>>> r = c.request('GET','/','',h)
send: 'GET / HTTP/1.1\r\nHost: localhost\r\nAccept-Encoding: identity\r\nX-A: a\r\nX-B: b\r\nX-C: c\r\n\r\n'
于 2012-09-17T11:38:58.853 回答