I’m trying to create a loop but it doesn’t wait loadFinished signal:
if __name__ == "__main__":
app = QApplication(sys.argv)
for line in open('proxy_list_test.txt', 'r').readlines():
network_data = line.split(':')
ip = network_data[0]
port = network_data[1]
print "Connecting with ip: %s port: %s"%(ip,port)
br = Browser(ip, port)
url = QUrl('http://example web site.com/')
br.load(url)
br.show()
print "Closing"
app.exec_()
As you can see I’m trying to load example web site with couple different ip addresses.
from Browser() they passed to NetworkAccessManager where I do :
proxy = QNetworkProxy(QNetworkProxy.HttpProxy, self.ip, self.port)
self.setProxy(proxy)
The problem is: when my file has only 1 IP address it works fine! But if it has couple of them, than the output in console is weired, it goes through the for loop and doesn’t wait until load Finished in Browser() class.
Connecting with ip: some_ip port: some_port
10%
Closing
Connecting with ip: some_ip port: some_port
10%
Closing
Connecting with ip: some_ip port: some_port
10%
Closing
Done
100%
and loadFinished and loadProgress SIGNALS are simple as that:
def _progress(self, progress):
print str(progress) + "%"
def _loadFinished(self):
print "Done"
Try this code before calling
br.load(url):This is assuming your
BrowseremitsloadFinished(it is a subclass ofQWebView)