Question

I am using the urllib2 module in Python 2.6.4, running in Windows XP, to access a URL. I am making a post request, that does not involve cookies or https or anything too complicated. The domain is redirected in my C:\WINDOWS\system32\drivers\etc\hosts file. However, I would like the request from urllib2 to go to the "real" domain and ignore the entry in the hosts file. Is there any easy and practical way to do this?

I would prefer if the request has the domain name in it, for example:

GET www.example.com/foo.html

rather than

GET 123.45.67.89/foo.html

Forget about that last part if you want. I don't need to be that specific about what goes in the header.

Was it helpful?

Solution

Connect to the IP address and pass the Host header manually.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top