Overriding hostname IP address in qtwebkit request
I'm downloading a web page (with PyQt4/QtWebKit) using given hostname, but I would like to use a pre-defined IP address for that hostname. For example, I need to hit "http://www.mysite.com" but use the IP address 1.2.3.4 instead of the actual resolved IP address. Is this at all possible in QtWebKit? I've tried a couple things so far:
Hitting http://1.2.3.4/ and sending a "Host" header of "www.mysite.com". This almost works, but ends up failing for a number of reasons (I'd be happy to go into more detail here).
Using a global /etc/hosts sett开发者_运维知识库ing. This didn't work because it is hard to automate and I will be doing multiple downloads at once.
Is there a way to either in python or in PyQt4/QtWebKit to override the IP address associated with a hostname?
This is big for me. Any help at all would be greatly appreciated.
Use custom network access manager, something like this (C++): http://ariya.blogspot.com/2010/05/qnetworkaccessmanager-tracenet-speed.html, so that you can "hijack" the network request and "redirect" it to other domain.
精彩评论