I’m using my own resolver and would like to use urllib2 to just connect to the IP (no resolving in urllib2) and I would like set the HTTP Host-header myself.
1 2 | txheaders = { "User-Agent": UA, "Host": nohttp_url } robots = urllib2.Request("http://" + ip + "/robots.txt", txdata, txheaders) |
source:http://stackoverflow.com/questions/3520966/set-host-header-when-using-python-and-urllib2