1

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:

  1. 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).

  2. Using a global /etc/hosts setting. 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.

4

1 回答 1

0

使用自定义网络访问管理器,像这样(C++):http ://ariya.blogspot.com/2010/05/qnetworkaccessmanager-tracenet-speed.html ,这样你就可以“劫持”网络请求并“重定向”它到其他域。

于 2010-12-23T04:08:09.160 回答