forked from noob77777/codechef_rating_v0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.py
29 lines (21 loc) · 830 Bytes
/
page.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys
from PyQt5.QtWebEngineWidgets import QWebEnginePage
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl
headers = {
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'}
class Page(QWebEnginePage):
QA = QApplication(sys.argv)
def __init__(self, url):
self.app = Page.QA
QWebEnginePage.__init__(self)
self.html = ''
self.loadFinished.connect(self._on_load_finished)
self.load(QUrl(url))
self.app.exec_()
def _on_load_finished(self):
self.html = self.toHtml(self.Callable)
print('JavaScript Loaded.')
def Callable(self, html_str):
self.html = html_str
self.app.quit()