예제 #1
0
    def start_browser(self):
        cookie_jar = QtNetwork.QNetworkCookieJar()
        self.web_page.networkAccessManager().setCookieJar(cookie_jar)

        self.ui.webView.load(
            QtCore.QUrl("http://%s:%d" %
                        (sc_globals.LOCAL_ADDRESS, sc_globals.LOCAL_PORT)))
        self.ui.webView.show()
예제 #2
0
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.tabs = QtGui.QTabWidget(
            self,
            tabsClosable=True,
            movable=True,
            currentChanged=self.currentTabChanged,
            elideMode=QtCore.Qt.ElideRight,
            tabCloseRequested=lambda idx: self.tabs.widget(idx).deleteLater())
        self.setCentralWidget(self.tabs)
        self.bars = {}
        self.star = QtGui.QAction(QtGui.QIcon.fromTheme("emblem-favorite"),
                                  "Bookmark",
                                  self,
                                  checkable=True,
                                  triggered=self.bookmarkPage,
                                  shortcut="Ctrl+d")
        self.tabs.setCornerWidget(
            QtGui.QToolButton(self,
                              text="New Tab",
                              icon=QtGui.QIcon.fromTheme("document-new"),
                              clicked=lambda: self.addTab().url.setFocus(),
                              shortcut="Ctrl+t"))
        self.addAction(
            QtGui.QAction("Full Screen",
                          self,
                          checkable=True,
                          toggled=lambda v: self.showFullScreen()
                          if v else self.showNormal(),
                          shortcut="F11"))
        self.bookmarks = self.get("bookmarks", {})
        self.bookmarkPage()  # Load the bookmarks menu
        self.history = self.get("history", []) + self.bookmarks.keys()
        self.completer = QtGui.QCompleter(
            QtCore.QStringList([QtCore.QString(u) for u in self.history]))

        # Use a app-wide, persistent cookiejar
        self.cookies = QtNetwork.QNetworkCookieJar(
            QtCore.QCoreApplication.instance())
        self.cookies.setAllCookies([
            QtNetwork.QNetworkCookie.parseCookies(c)[0]
            for c in self.get("cookiejar", [])
        ])

        # Downloads bar at the bottom of the window
        self.downloads = QtGui.QToolBar("Downloads")
        self.addToolBar(QtCore.Qt.BottomToolBarArea, self.downloads)

        # Proxy support
        proxy_url = QtCore.QUrl(os.environ.get('http_proxy', ''))
        QtNetwork.QNetworkProxy.setApplicationProxy(
            QtNetwork.QNetworkProxy(
                QtNetwork.QNetworkProxy.HttpProxy if unicode(proxy_url.scheme(
                )).startswith('http') else QtNetwork.QNetworkProxy.Socks5Proxy,
                proxy_url.host(), proxy_url.port(), proxy_url.userName(),
                proxy_url.password())) if 'http_proxy' in os.environ else None

        [self.addTab(QtCore.QUrl(u)) for u in self.get("tabs", [])]
예제 #3
0
    def __init__(self, parent=None):
        super(App, self).__init__(parent)

        x, y, w, h = 500, 200, 1024, 768
        self.setGeometry(x, y, w, h)
        self.setFixedSize(w, h)

        self.url_lineedit = QtGui.QLineEdit(self)
        self.url_lineedit.setGeometry(0, 0, 900, 22)
        self.connect(self.url_lineedit, QtCore.SIGNAL('returnPressed()'),
                     self.url_returnPressed)

        self.progressbar = QtGui.QProgressBar(self)
        self.progressbar.setGeometry(900, 0, 124, 22)
        self.progressbar.setMinimum(0)
        self.progressbar.setMaximum(100)

        self.webview = QtWebKit.QWebView(self)
        qsettings = self.webview.settings()
        qsettings.setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled,
                               True)

        self.inspector = QtWebKit.QWebInspector(self)
        self.inspector.setPage(self.webview.page())
        self.inspector.setGeometry(0, h - 200, w, 200)
        self.inspector.setVisible(True)

        self.webview.setGeometry(0, 22, w, h - 200)
        self.connect(self.webview, QtCore.SIGNAL("loadStarted()"),
                     self.webview_loadStarted)
        self.connect(self.webview, QtCore.SIGNAL("loadFinished(bool)"),
                     self.webview_loadFinished)
        self.connect(self.webview, QtCore.SIGNAL('loadProgress(int)'),
                     self.webview_loadProgress)

        cache = QtNetwork.QNetworkDiskCache()
        dir = QtGui.QDesktopServices.storageLocation(
            QtGui.QDesktopServices.CacheLocation)
        cache.setCacheDirectory(dir)
        self.am = self.webview.page().networkAccessManager()
        self.am.setCache(cache)

        self.cj = QtNetwork.QNetworkCookieJar()
        self.am.setCookieJar(self.cj)

        self._portal_url = "http://www.baidu.com/"
        self.url_lineedit.setText(self._portal_url)
        self.webview.load(QtCore.QUrl(self._portal_url))

        self.url_lineedit.setFocus()
        self.setup_global_shortcuts()
예제 #4
0
    def __init__(self, *args):
        QtGui.QMainWindow.__init__(self, *args)
        self.resize(400, 500)
        self.setWindowTitle("Google Tasks")

        # Cookies laden
        self.cookiejar = QtNetwork.QNetworkCookieJar(self)
        settings = QtCore.QSettings("dasskript.com", "GoogleTasks")
        cookie_list = settings.value("cookies", "").toString()
        if cookie_list != "":
            cookie_list = pickle.loads(base64.b64decode(cookie_list))
            cookies = self._cookiesFromCookieList(cookie_list)
            self.cookiejar.setCookiesFromUrl(
                cookies, QtCore.QUrl("https://mail.google.com/tasks/ig"))
        self.page().networkAccessManager().setCookieJar(self.cookiejar)

        self.load(QtCore.QUrl("https://mail.google.com/tasks/ig"))
예제 #5
0
파일: RWebKit.py 프로젝트: Tamh/ryouko
 def establishPBMode(self, pb):
     self.pb = pb
     if not pb or pb == None:
         self.settings().setAttribute(
             QtWebKit.QWebSettings.PrivateBrowsingEnabled, True)
     else:
         self.settings().setAttribute(
             QtWebKit.QWebSettings.PrivateBrowsingEnabled, False)
     if not pb:
         try:
             self.setCookieJar(self.cookieJar)
         except:
             pass
     else:
         cookies = QtNetwork.QNetworkCookieJar(None)
         cookies.setAllCookies([])
         self.page().networkAccessManager().setCookieJar(cookies)
     if (unicode(self.url().toString()) == "about:blank"
             or unicode(self.url().toString())
             == "") and self.pb != None and self.pb != False:
         self.buildNewTabPage()
예제 #6
0
    def __init__(self, url, request_cookiejar):
        super(NikeBrowser, self).__init__()

        self.setWindowTitle('终结者浏览器')

        # 将字典转化成QNetworkCookieJar的格式
        self.cookie_jar = QtNetwork.QNetworkCookieJar()
        cookies = []
        # 直接通过cookie.name和cookie.value的方式迭代
        for cookie in request_cookiejar:
            my_cookie = QtNetwork.QNetworkCookie(
                QtCore.QByteArray(cookie.name),
                QtCore.QByteArray(cookie.value))
            my_cookie.setDomain('.nike.com')
            cookies.append(my_cookie)
        self.cookie_jar.setAllCookies(cookies)
        self.page().networkAccessManager().setCookieJar(self.cookie_jar)
        # self.cookie_jar.setCookiesFromUrl(cookies, QUrl
        # ('https://secure-store.nike.com/cn/checkout/html/cart.jsp?country=CN&l=cart&site=nikestore&returnURL=http://www.nike.com/cn/zh_cn/'))
        self.load(QtCore.QUrl(url))
        self.show()
예제 #7
0
    def Browse(self, url):
        MainWindow = QtGui.QWidget()
        progress = QtGui.QProgressDialog("Please Wait", "Cancel", 0, 100,
                                         MainWindow)
        progress.setWindowModality(QtCore.Qt.WindowModal)
        progress.setAutoReset(True)
        progress.setAutoClose(True)
        progress.setMinimum(0)
        progress.setMaximum(100)
        progress.resize(500, 100)
        progress.setWindowTitle(
            "Loading, Please Wait! (Cloudflare Protection)")
        progress.show()
        progress.setValue(0)

        print('Browse: ' + url)
        self.web = Browser(url)
        self.cookie = QtNetwork.QNetworkCookieJar()

        self.nam = NetWorkManager()
        self.nam.setCookieJar(self.cookie)

        self.web.page().setNetworkAccessManager(self.nam)
        self.web.load(QUrl(url))
        cnt = 0

        if 'kissmanga' in url:
            cookie_file = '/tmp/ReadManga/kcookieM.txt'

        while (not os.path.exists(cookie_file) and cnt < 60):
            print('wait ' + str(cnt))
            time.sleep(1)
            QtGui.QApplication.processEvents()
            cnt = cnt + 1
        if cnt >= 60 and not os.path.exists(cookie_file):
            f = open(cookie_file, 'w')
            f.close()
        self.web.setHtml('<html>Cookie Obtained</html>')
        progress.setValue(100)
        progress.hide()
예제 #8
0
파일: RWebKit.py 프로젝트: Tamh/ryouko
    def __init__(self,
                 parent=False,
                 settingsManager=None,
                 pb=False,
                 app_profile=os.path.expanduser("~"),
                 sm=None,
                 user_links="",
                 downloadManager=None):
        QtWebKit.QWebView.__init__(self, parent)
        self.settingsManager = settingsManager
        self.user_links = user_links
        self.searchManager = sm
        self.downloadManager = downloadManager
        self.app_profile = app_profile
        self.setCookieJar(QtNetwork.QNetworkCookieJar(None))
        self.parent2 = parent
        page = RWebPage(self)
        self.setPage(page)
        self.settingsManager = None
        self.loading = False
        self.destinations = []
        self.sourceViews = []
        self.autoSaveInterval = 0
        self.urlChanged.connect(self.autoSave)
        self.printer = None
        self.replies = []
        self.newWindows = [0]
        #self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
        #self.page().linkClicked.connect(self.openLink)
        self.settings().setAttribute(
            QtWebKit.QWebSettings.DeveloperExtrasEnabled, True)
        #        if os.path.exists(app_logo):
        #            self.setWindowIcon(QtGui.QIcon(app_logo))
        if pb:
            self.setWindowTitle("Ryouko (PB)")
        else:
            self.setWindowTitle("Ryouko")
        if parent == False:
            self.setParent(None)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Expanding)

        self.text = ""
        self.zoomFactor = 1.0

        self.titleChanged.connect(self.updateTitle)

        self.viewSourceAction = QtGui.QAction(self)
        #self.viewSourceAction.setShortcut("Ctrl+Alt+U")
        self.viewSourceAction.triggered.connect(self.viewSource)
        self.addAction(self.viewSourceAction)

        self.buildNewTabPageAction = QtGui.QAction(self)
        self.buildNewTabPageAction.setShortcut("F1")
        self.buildNewTabPageAction.triggered.connect(self.buildNewTabPage)
        self.addAction(self.buildNewTabPageAction)

        self.newWindowAction = QtGui.QAction(self)
        self.newWindowAction.triggered.connect(self.newWindow)
        self.addAction(self.newWindowAction)

        self.closeWindowAction = QtGui.QAction(self)
        self.closeWindowAction.triggered.connect(self.close)
        self.addAction(self.closeWindowAction)

        self.backAction = QtGui.QAction(self)
        self.backAction.setShortcut("Alt+Left")
        self.backAction.triggered.connect(self.back)
        self.addAction(self.backAction)

        self.savePageAction = QtGui.QAction(self)
        self.savePageAction.triggered.connect(self.savePage)
        self.addAction(self.savePageAction)

        self.printPageAction = QtGui.QAction(self)
        self.printPageAction.triggered.connect(self.printPreview)
        self.addAction(self.printPageAction)

        self.nextAction = QtGui.QAction(self)
        self.nextAction.setShortcut("Alt+Right")
        self.nextAction.triggered.connect(self.forward)
        self.addAction(self.nextAction)

        self.stopAction = QtGui.QAction(self)
        self.stopAction.triggered.connect(self.stop)
        self.addAction(self.stopAction)

        self.reloadAction = QtGui.QAction(self)
        self.reloadAction.triggered.connect(self.reload)
        self.reloadAction.setShortcuts(["Ctrl+R", "F5"])
        self.addAction(self.reloadAction)

        self.locationEditAction = QtGui.QAction(self)
        self.locationEditAction.triggered.connect(self.locationEdit)
        self.addAction(self.locationEditAction)

        self.zoomInAction = QtGui.QAction(self)
        self.zoomInAction.triggered.connect(self.zoomIn)
        self.addAction(self.zoomInAction)

        self.zoomOutAction = QtGui.QAction(self)
        self.zoomOutAction.triggered.connect(self.zoomOut)
        self.addAction(self.zoomOutAction)

        self.zoomResetAction = QtGui.QAction(self)
        self.zoomResetAction.triggered.connect(self.zoomReset)
        self.addAction(self.zoomResetAction)

        self.undoCloseWindowAction = QtGui.QAction(tr('undoCloseWindow'), self)
        self.undoCloseWindowAction.triggered.connect(
            self.undoCloseWindowRequest.emit)
        self.addAction(self.undoCloseWindowAction)

        #self.page().action(QtWebKit.QWebPage.InspectElement).setShortcut("F12")
        self.page().action(QtWebKit.QWebPage.InspectElement).triggered.connect(
            self.showInspector)
        self.addAction(self.page().action(QtWebKit.QWebPage.InspectElement))

        self.page().setForwardUnsupportedContent(True)
        self.hoveredUrl = QtCore.QUrl("about:blank")
        self.page().linkHovered.connect(self.setHoveredUrl)
        self.page().unsupportedContent.connect(self.downloadUnsupportedContent)
        self.page().downloadRequested.connect(self.downloadFile)
        self.loadFinished.connect(self.checkForAds)
        if sys.platform.startswith("win"):
            self.loadFinished.connect(self.replaceAV)
        self.updateSettings()
        self.establishPBMode(pb)
        self.loadFinished.connect(self.setLoadingFalse)
        self.loadProgress.connect(self.setLoadingTrue)
        if (unicode(self.url().toString()) == "about:blank"
                or unicode(self.url().toString()) == ""):
            self.buildNewTabPage()
        else:
            self.isWindow = False
        self.loadFinished.connect(self.loadLinks)
예제 #9
0
#!/usr/bin/env python
#-*- coding:utf-8 -*-

from PyQt4 import QtGui, QtCore, QtWebKit, QtNetwork
from twisted.internet.defer import inlineCallbacks, returnValue
import socket

SIGNALID1 = 445567

cookieJar = QtNetwork.QNetworkCookieJar()

networkAccessManager = QtNetwork.QNetworkAccessManager()
networkAccessManager.setCookieJar(cookieJar)

class myWebView(QtWebKit.QWebView):
    _windows = set()

    def __init__(self, parent=None):
        super(myWebView, self).__init__(parent)
        self.settings().setAttribute(QtWebKit.QWebSettings.JavascriptEnabled, True)
        self.settings().setAttribute(QtWebKit.QWebSettings.JavascriptCanOpenWindows, True)
        self.settings().setAttribute(QtWebKit.QWebSettings.JavascriptCanAccessClipboard, True)
        self.page().setNetworkAccessManager(networkAccessManager)

        url = url = QtCore.QUrl("http://10.97.112.16/control.htm")
        url.setUserName("main")
        url.setPassword("main")
        self.load(url)

    @classmethod
    def _removeWindow(cls, window):
예제 #10
0
    def Browse(self, url, quality):

        if 'kissanime' in url:
            cookie_file = '/tmp/AnimeWatch/kcookie.txt'
        elif 'kisscartoon' in url:
            cookie_file = '/tmp/AnimeWatch/kcookieC.txt'
        elif 'kissasian' in url:
            cookie_file = '/tmp/AnimeWatch/kcookieD.txt'
        elif 'masterani' in url:
            cookie_file = '/tmp/AnimeWatch/animeSquare.txt'
        elif 'animeget' in url:
            cookie_file = '/tmp/AnimeWatch/animeget.txt'
        elif 'animeplace' in url:
            cookie_file = '/tmp/AnimeWatch/animeplace.txt'
        elif 'moetube' in url:
            cookie_file = '/tmp/AnimeWatch/animeHQ.txt'
            #if os.path.exists(cookie_file):
            #	os.remove(cookie_file)

        if 'animeget' in url or 'masterani' in url or 'animeplace' in url or 'moetube' in url:
            content = ccurl(url)
        else:
            content = 'checking_browser'

        if 'checking_browser' in content:
            if not os.path.exists(cookie_file):

                self.cookie = QtNetwork.QNetworkCookieJar()
                self.nam = NetWorkManager()
                self.nam.setCookieJar(self.cookie)
            else:
                cookie_arr = QtNetwork.QNetworkCookieJar()
                c = []
                f = open(cookie_file, 'r')
                lines = f.readlines()
                f.close()
                for i in lines:
                    k = re.sub('\n', '', i)
                    l = k.split('	')
                    d = QtNetwork.QNetworkCookie()
                    d.setDomain(l[0])
                    if l[1] == 'TRUE':
                        l1 = True
                    else:
                        l1 = False
                    d.setHttpOnly(l1)
                    d.setPath(l[2])
                    if l[3] == 'TRUE':
                        l3 = True
                    else:
                        l3 = False
                    d.setSecure(l3)
                    l4 = int(l[4])
                    print(l4)
                    d.setExpirationDate(QtCore.QDateTime.fromTime_t(l4))
                    d.setName(l[5])
                    d.setValue(l[6])
                    c.append(d)
                    #cookie_arr.append(d)
                cookie_arr.setAllCookies(c)
                self.nam = NetWorkManager()
                self.nam.setCookieJar(cookie_arr)

            self.web = Browser(url, quality)
            self.tab_2 = QtGui.QWidget()
            self.tab_2.setMaximumSize(300, 50)
            self.tab_2.setWindowTitle('Wait!')
            self.horizontalLayout_5 = QtGui.QVBoxLayout(self.tab_2)
            print('Browse: ' + url)

            self.horizontalLayout_5.addWidget(self.web)
            self.tab_2.show()
            #self.tab_2.hide()
            #self.web.show()
            self.web.page().setNetworkAccessManager(self.nam)
            self.web.load(QUrl(url))
            cnt = 0

            while (not os.path.exists(cookie_file) and cnt < 20):
                #print()
                print('wait Clouflare ')
                time.sleep(1)
                QtGui.QApplication.processEvents()
                cnt = cnt + 1
                self.tab_2.setWindowTitle('Wait! Cloudflare ' + str(cnt) + 's')

            if cnt >= 20 and not os.path.exists(cookie_file):
                f = open(cookie_file, 'w')
                f.close()
            lnk_file = '/tmp/AnimeWatch/lnk.txt'
            if os.path.exists(lnk_file):
                os.remove(lnk_file)
            cnt = 0
            if ('kisscartoon' in url or 'kissasian' in url) and quality:
                while (not os.path.exists(lnk_file) and cnt < 20):
                    print('wait Finding Link ')
                    time.sleep(1)
                    QtGui.QApplication.processEvents()
                    cnt = cnt + 1
                    self.tab_2.setWindowTitle('Link Resolving ' + str(cnt) +
                                              's')

                if os.path.exists(lnk_file):
                    self.web.setHtml('<html>Link Obtained</html>')
                    link = open(lnk_file).read()
                    print(link)
                else:
                    self.web.setHtml('<html>No Link Found</html>')
                    print('No Link Available or Clear The Cache')
            else:
                self.web.setHtml('<html>cookie Obtained</html>')
            self.tab_2.hide()
        else:
            f = open(cookie_file, 'w')
            f.close()