[PyQt] Different QWebView objects gives identical output for same urls
Герасимов Михаил
Gerasimov-M-N at yandex.ru
Wed Feb 11 14:04:06 GMT 2015
I found that if we load one url with different QWebView objects
parallely, we will have identical output: only one of this QWebView will
make real request. Here is example:
> from PyQt5.QtCore import QUrl
> from PyQt5.QtWidgets import QApplication
> from PyQt5.QtWebKitWidgets import QWebView
>
> def load_and_print(url):
> view = QWebView()
> view.load(QUrl(url))
> def on_ready(ok):
> print(view.page().mainFrame().documentElement().toPlainText())
> view.loadFinished.connect(on_ready)
>
> if __name__ == '__main__':
> app = QApplication([])
>
> # This url outputs random number:
> url =
> 'https://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new'
> load_and_print(url)
> load_and_print(url)
>
> app.exec_()
>
> # output:
> # 39
> # 39
It was surprising. How can we get "fair", unique output for each
QWebView object, If url is the same?
More information about the PyQt
mailing list