This repository has been archived by the owner on Oct 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
insider.py
35 lines (30 loc) · 1.49 KB
/
insider.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
30
31
32
33
34
35
import os
from PyQt4 import uic, QtWebKit
from PyQt4.QtWebKit import QWebPage, QWebView
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtNetwork import *
class InsiderWebPage(QWebPage):
def acceptNavigationRequest(self, frame, req, nav_type):
if nav_type == QWebPage.NavigationTypeFormSubmitted:
QDesktopServices.openUrl(req.url())
return True
else:
return super(InsiderWebPage, self).acceptNavigationRequest(frame, req, nav_type)
class Insider(QObject):
def __init__(self, cookies):
super(Insider, self).__init__()
self.widget = uic.loadUi('ui/insider.ui')
self.widget.setFixedSize(700, 550)
self.cookies = QNetworkCookie.parseCookies('T=' + cookies['T'] + '\r\nY=' + cookies['Y'])
self.cookieJar = QNetworkCookieJar()
self.cookieJar.setAllCookies(self.cookies)
self.widget.webView.setPage(InsiderWebPage())
self.widget.webView.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(os.getcwd() + '/ui/insider.css'))
self.widget.webView.page().networkAccessManager().setCookieJar(self.cookieJar)
self.widget.webView.setUrl(QUrl('http://insider.msg.yahoo.com/?fmt=2.0&intl=us&os=win&ver=11.5.0.192&lang=en-US&fr=cwbtn&t=0'))
self.widget.webView.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
self.widget.webView.linkClicked.connect(self.open_url)
self.widget.show()
def open_url(self, url):
QDesktopServices.openUrl(url)