def __init__(self,base_url=None, gui=False, user_agent=None, proxy=None, allowed_media=None, allowed_regex='.*?', timeout=2, delay=5, enable_plugins=True):#, cache_file=None): """ base_url is the domain that will be crawled gui is whether to show webkit window or run headless user_agent is used to set the user-agent when downloading content proxy is a QNetworkProxy to download through allowed_media are the media extensions to allow allowed_regex is a regular expressions of URLS to allow timeout is the maximum amount of seconds to wait for a request delay is the minimum amount of seconds to wait between requests """ self.app = QApplication(sys.argv) # must instantiate first QWebView.__init__(self) webpage = WebPage(user_agent or random.choice(settings.user_agents)) allowed_media = allowed_media or ['css', 'js'] manager = NetworkAccessManager(proxy, allowed_media, allowed_regex) self.manager = manager manager.finished.connect(self.finished) webpage.setNetworkAccessManager(manager) self.setPage(webpage) self.setHtml('<html><head></head><body>No content loaded</body></html>', QUrl('http://localhost')) self.timeout = timeout self.delay = delay #self.cache = pdict.PersistentDict(cache_file or settings.cache_file) # cache to store webpages self.base_url = base_url self.jquery_lib = None #enable flash plugin etc. self.settings().setAttribute(QWebSettings.PluginsEnabled, enable_plugins) #XXXQTimer.singleShot(0, self.run) # start crawling when all events processed if gui: self.show() #self.show() self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) self.page().linkClicked.connect(self.linkClick)
def __init__(self, base_url=None, gui=False, user_agent=None, proxy=None, allowed_extensions=['.html', '.css', '.js'], timeout=20, cache_file=None, debug=False): """ base_url is the domain that will be crawled gui is whether to show webkit window or run headless user_agent is used to set the user-agent when downloading content proxy is the proxy to download through allowed_extensions are the media types to allow timeout is the maximum amount of seconds to wait for a request """ self.app = QApplication(sys.argv) # must instantiate first QWebView.__init__(self) webpage = WebPage(user_agent or settings.user_agents[0]) manager = NetworkAccessManager(proxy, allowed_extensions) manager.finished.connect(self.finished) webpage.setNetworkAccessManager(manager) self.setPage(webpage) self.setHtml('<html><head></head><body>No content loaded</body></html>', QUrl('http://localhost')) self.timeout = timeout self.cache = pdict.PersistentDict(cache_file or settings.cache_file) # cache to store webpages self.base_url = base_url self.debug = debug self.jquery_lib = None QTimer.singleShot(0, self.crawl) # start crawling when all events processed if gui: self.show() self.app.exec_() # start GUI thread
def __init__(self, vertical, parent=None): QWebView.__init__(self, parent) s = self.settings() s.setAttribute(s.JavascriptEnabled, False) self.vertical = vertical self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks) self.linkClicked.connect(self.link_activated) self._link_clicked = False self.setAttribute(Qt.WA_OpaquePaintEvent, False) palette = self.palette() self.setAcceptDrops(False) palette.setBrush(QPalette.Base, Qt.transparent) self.page().setPalette(palette) self.css = P('templates/book_details.css', data=True).decode('utf-8') for x, icon in [('remove_format', 'trash.png'), ('save_format', 'save.png'), ('restore_format', 'edit-undo.png'), ('copy_link', 'edit-copy.png'), ('manage_author', 'user_profile.png'), ('compare_format', 'diff.png')]: ac = QAction(QIcon(I(icon)), '', self) ac.current_fmt = None ac.current_url = None ac.triggered.connect(getattr(self, '%s_triggerred' % x)) setattr(self, '%s_action' % x, ac)
def __init__(self, vertical, parent=None): QWebView.__init__(self, parent) s = self.settings() s.setAttribute(s.JavascriptEnabled, False) self.vertical = vertical self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks) self.linkClicked.connect(self.link_activated) self._link_clicked = False self.setAttribute(Qt.WA_OpaquePaintEvent, False) palette = self.palette() self.setAcceptDrops(False) palette.setBrush(QPalette.Base, Qt.transparent) self.page().setPalette(palette) self.css = P("templates/book_details.css", data=True).decode("utf-8") for x, icon in [ ("remove_format", "trash.png"), ("save_format", "save.png"), ("restore_format", "edit-undo.png"), ("copy_link", "edit-copy.png"), ("manage_author", "user_profile.png"), ("compare_format", "diff.png"), ]: ac = QAction(QIcon(I(icon)), "", self) ac.current_fmt = None ac.current_url = None ac.triggered.connect(getattr(self, "%s_triggerred" % x)) setattr(self, "%s_action" % x, ac)
def __init__(self, *args): QWebView.__init__(self, *args) self.gui = None self.tags = '' self.setPage(NPWebPage()) self.page().networkAccessManager().setCookieJar(QNetworkCookieJar()) http_proxy = get_proxies().get('http', None) if http_proxy: proxy_parts = urlparse(http_proxy) proxy = QNetworkProxy() proxy.setType(QNetworkProxy.HttpProxy) if proxy_parts.username: proxy.setUser(proxy_parts.username) if proxy_parts.password: proxy.setPassword(proxy_parts.password) if proxy_parts.hostname: proxy.setHostName(proxy_parts.hostname) if proxy_parts.port: proxy.setPort(proxy_parts.port) self.page().networkAccessManager().setProxy(proxy) self.page().setForwardUnsupportedContent(True) self.page().unsupportedContent.connect(self.start_download) self.page().downloadRequested.connect(self.start_download) self.page().networkAccessManager().sslErrors.connect( self.ignore_ssl_errors)
def __init__(self, html, resolution): QWebView.__init__(self) self.resolution = resolution self.finished = False self.out = "web2png.%i.png"%int(random.randint(0,1000)) #self.web_view = QWebView() #self.css_file = QString('/home/ddimitrov/wikiwsd/data/wikipedia_css.css') #path = os.getcwd() #self.settings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True) #self.settings().setAttribute(QWebSettings.LocalContentCanAccessFileUrls, True) #self.web_view.settings().setUserStyleSheetUrl(QUrl.fromLocalFile("wikipedia_css.css")) #self.web_view.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(QString('file:///home/ddimitrov/wikiwsd/wikipedia_css.css'))) #print self.web_view.settings().userStyleSheetUrl() #self.web_view.settings().setAttribute(QWebSettings.AutoLoadImages, False) #self.web_view.settings().setAttribute(QWebSettings.JavascriptEnabled, False) #self.setCentralWidget(self.web_view) #self.resize(resolution[0], resolution[1]) self.loadFinished.connect(self._load_finished) #self.loadProgress.connect(self._loadProgress) self.setHtml(html)
def __init__(self, html, resolution): QWebView.__init__(self) self.resolution = resolution self.finished = False self.out = "web2png.%i.png" % int(random.randint(0, 1000)) #self.web_view = QWebView() #self.css_file = QString('/home/ddimitrov/wikiwsd/data/wikipedia_css.css') #path = os.getcwd() #self.settings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True) #self.settings().setAttribute(QWebSettings.LocalContentCanAccessFileUrls, True) #self.web_view.settings().setUserStyleSheetUrl(QUrl.fromLocalFile("wikipedia_css.css")) #self.web_view.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(QString('file:///home/ddimitrov/wikiwsd/wikipedia_css.css'))) #print self.web_view.settings().userStyleSheetUrl() #self.web_view.settings().setAttribute(QWebSettings.AutoLoadImages, False) #self.web_view.settings().setAttribute(QWebSettings.JavascriptEnabled, False) #self.setCentralWidget(self.web_view) #self.resize(resolution[0], resolution[1]) self.loadFinished.connect(self._load_finished) #self.loadProgress.connect(self._loadProgress) self.setHtml(html)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) QWebView.__init__(self) self.ui = BrowserDialog() self.ui.setupUi(self) self.ui.lineEdit.returnPressed.connect(self.loadURL)
def __init__(self): QWebView.__init__(self) self.createTrayIcon() self.resize(400, 200) self.setHtml(""" <script> function message() { return "jsClicked!"; } </script> <h1>QtWebKit + Python sample program</h1> <input type="button" value="Click JavaScript!" onClick="alert('[javascript] ' + message())"/> <input type="button" value="Click int!" onClick="alert('[python] ' + python.message(5))"/> <input type="button" value="Click string!" onClick="alert('[python] ' + python.message1('55','1f'))"/> <br /> """) self.show() self.trayIcon.show()
def __init__(self,parent=None): ''' zoom: zoom out times openedpg: current openedpage signal 'openUrl' will be emited(with param url:unicode) signal 'openatnewtab' will be emited(with param url:unicode) signal 'openremoteatnewtab' will be emited(with param url:unicode) signal 'openRemoteUrl' will be emited(with param url:unicode) ''' QWebView.__init__(self,parent) self.page().setNetworkAccessManager(PyChmNetworkAccessManager(self)) self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) #self.setUrl(QtCore.QUrl('http://www.baidu.com')) self.connect(self,QtCore.SIGNAL('linkClicked(const QUrl&)'),self.onLinkClicked) # self.connect(self.zob,QtCore.SIGNAL('clicked()'),self.zoomout) # self.connect(self.zib,QtCore.SIGNAL('clicked()'),self.zoomin) # self.connect(self.normb,QtCore.SIGNAL('clicked()'),self.normsize) # self.connect(self.bb,QtCore.SIGNAL('clicked()'),self.back) # self.connect(self.fb,QtCore.SIGNAL('clicked()'),self.forward) self.connect(self,QtCore.SIGNAL('loadFinished(bool)'),self.onLoadFinished) self.zoom=1.0 self.setTextSizeMultiplier(1.0) self.reload() self.openedpg=None self.scrolltopos=0
def __init__(self, url): self.app = QApplication(sys.argv) QWebView.__init__(self) self.loadFinished.connect(self._loadFinished) self.load(QUrl(url)) self.app.exec_()
def __init__(self, name, app, scope, r_server, delay=1, proxy=None, forbidden_extensions=None, allowed_regex='.*?'): QWebView.__init__(self) self.name = name self.app = app self.scope = scope self.r_server = r_server self.delay = delay self.current_level = -1 self.async_res = [] self._t_pool = dict() LOGGER.debug("<%s> Initialized" % name) manager = NetworkAccessManager(proxy, forbidden_extensions, allowed_regex) manager.finished.connect(self._on_finished) webpage = WebPage("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.94 Chrome/37.0.2062.94 Safari/537.36") webpage.setNetworkAccessManager(manager) #webpage.mainFrame().javaScriptWindowObjectCleared.connect(self._on_jsWinObjCleared) self.setHtml('<html><head></head><body><h1>Multithreaded Crawler</h1><p>Waiting for orders, sir!</p></body></html>', QUrl('http://localhost')) self.setPage(webpage) self.loadFinished.connect(self._on_loadFinished) self.settings().setAttribute(QWebSettings.PluginsEnabled, True) self.settings().setAttribute(QWebSettings.JavaEnabled, True) self.settings().setAttribute(QWebSettings.AutoLoadImages, True) self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
def __init__(self, base_url=None, gui=False, user_agent=None, proxy=None, allowed_media=None, allowed_regex='.*?', timeout=20, delay=5, enable_plugins=True):#, cache_file=None): """ base_url is the domain that will be crawled gui is whether to show webkit window or run headless user_agent is used to set the user-agent when downloading content proxy is a QNetworkProxy to download through allowed_media are the media extensions to allow allowed_regex is a regular expressions of URLS to allow timeout is the maximum amount of seconds to wait for a request delay is the minimum amount of seconds to wait between requests """ self.app = QApplication(sys.argv) # must instantiate first QWebView.__init__(self) webpage = WebPage(user_agent or random.choice(settings.user_agents)) allowed_media = allowed_media or ['css', 'js'] manager = NetworkAccessManager(proxy, allowed_media, allowed_regex) manager.finished.connect(self.finished) webpage.setNetworkAccessManager(manager) self.setPage(webpage) self.setHtml('<html><head></head><body>No content loaded</body></html>', QUrl('http://localhost')) self.timeout = timeout self.delay = delay #self.cache = pdict.PersistentDict(cache_file or settings.cache_file) # cache to store webpages self.base_url = base_url self.jquery_lib = None #enable flash plugin etc. self.settings().setAttribute(QWebSettings.PluginsEnabled, enable_plugins) #XXXQTimer.singleShot(0, self.run) # start crawling when all events processed if gui: self.show()
def __init__(self, *args): QWebView.__init__(self, *args) self.gui = None self.tags = '' self._page = NPWebPage() self.setPage(self._page) self.cookie_jar = QNetworkCookieJar() self.page().networkAccessManager().setCookieJar(self.cookie_jar) http_proxy = get_proxies().get('http', None) if http_proxy: proxy_parts = urlparse(http_proxy) proxy = QNetworkProxy() proxy.setType(QNetworkProxy.HttpProxy) if proxy_parts.username: proxy.setUser(proxy_parts.username) if proxy_parts.password: proxy.setPassword(proxy_parts.password) if proxy_parts.hostname: proxy.setHostName(proxy_parts.hostname) if proxy_parts.port: proxy.setPort(proxy_parts.port) self.page().networkAccessManager().setProxy(proxy) self.page().setForwardUnsupportedContent(True) self.page().unsupportedContent.connect(self.start_download) self.page().downloadRequested.connect(self.start_download) self.page().networkAccessManager().sslErrors.connect(self.ignore_ssl_errors)
def __init__(self): QWebView.__init__(self) self.loadFinished.connect(self._result_available) QtCore.QObject.connect( self, QtCore.SIGNAL("downloadRequested(const QNetworkRequest&)"), self.downloadRequested) self.netmanager = QtNetwork.QNetworkAccessManager(self)
def __init__(self, window): QWebView.__init__(self) self.window = window with open(Resources.get_path("leftpane.js"), "r") as f: self.js = f.read() # We don't want plugins for this simple pane self.settings().setAttribute(QWebSettings.PluginsEnabled, False) self.reset()
def __init__(self, parent=None): """ This method initializes the class. :param parent: Object parent. ( QObject ) """ QWebView.__init__(self, parent)
def __init__(self, page, ready_for_cmds, invoice_request_queue): QWebView.__init__(self) self.setWindowTitle(FRONTEND_WINDOW_TITLE) self.ready_for_cmds = ready_for_cmds self.page().loadFinished.connect(self.page_is_ready) self.page().mainFrame().addToJavaScriptWindowObject( "pyObj", JavascriptBridge(invoice_request_queue)) self.load(QtCore.QUrl(page))
def __init__(self, *args, **kwargs): QWebView.__init__(self, *args, **kwargs) MultiModelView.__init__(self, *args, **kwargs) self.setHtml("") # if self.open_link_in_external_browser(): self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) self.linkClicked.connect(self.link_clicked)
def __init__(self, html, timeout=6000): QWebView.__init__(self) self.setWindowFlags(Qt.ToolTip | Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint) self.setHtml(html) self.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) self.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) self.timeout = timeout self.resize(300, 100)
def __init__(self, name): QWebView.__init__(self) self.setPage(PlotWebPage(name)) self.setRenderHint(QPainter.Antialiasing, True) self.setContextMenuPolicy(Qt.NoContextMenu) self.settings().setAttribute(QWebSettings.JavascriptEnabled, True) self.settings().setAttribute(QWebSettings.LocalContentCanAccessFileUrls, True) self.settings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True) self.settings().clearMemoryCaches()
def __init__(self, parent=None): QWebView.__init__(self, parent) self.inspector = QWebInspector(self) w = QApplication.instance().desktop().availableGeometry(self).width() self._size_hint = QSize(int(w/3), int(w/2)) self._page = WebPage(self) self.setPage(self._page) self.inspector.setPage(self._page) self.clear()
def __init__(self, view: Amendment('view/', lambda v: hasattr(v, 'mode') and (v.mode.name == 'web') and (v.widget is None))): #, orig_editor=None): self.view = view QWebView.__init__(self) view.widget = self self.load(QUrl(view.filebuf.file_name)) self.page().setContentEditable(True) QNetworkProxyFactory.setUseSystemConfiguration(True); QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True); QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, True);
def __init__(self, parent): QWebView.__init__(self, parent) self.zoom_factor = 1. self.zoom_out_action = create_action(self, _("Zoom out"), icon=get_icon('zoom_out.png'), triggered=self.zoom_out) self.zoom_in_action = create_action(self, _("Zoom in"), icon=get_icon('zoom_in.png'), triggered=self.zoom_in)
def __init__(self, parent=None): """ Initializes the class. :param parent: Object parent. :type parent: QObject """ QWebView.__init__(self, parent)
def __init__(self, headers, data): QWebView.__init__(self) # Populate html table self.build_page(headers, data) # A proxy object is needed to communicate between Python and JavaScript self.proxy = Proxy(self) self.frame = self.page().mainFrame() self.frame.addToJavaScriptWindowObject("proxy", self.proxy) # The handle of the inspect window must be held self.inspector = None
def __init__(self, window): QWebView.__init__(self) self.window = window with open(get_resource_path("leftpane.js"), "r") as f: self.js = f.read() self.setFixedWidth(0) self.setVisible(False) self.setUrl(QUrl.fromLocalFile(get_resource_path("leftpane.html"))) self.page().currentFrame().addToJavaScriptWindowObject("leftPane", self) self.page().currentFrame().evaluateJavaScript(self.js)
def __init__(self, window): self.configure_proxy() QWebView.__init__(self) self.window = window with open(Resources.get_path("scudcloud.js"), "r") as f: self.js = f.read() self.setZoomFactor(self.window.zoom) self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) self.connect(self, SIGNAL("urlChanged(const QUrl&)"), self.urlChanged) self.connect(self, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked) self.addActions()
def __init__(self, imgs_dir=None): self.app = QApplication(sys.argv) locale.setlocale(locale.LC_ALL, "C") QWebView.__init__(self) self._loaded = False self.loadFinished.connect(self._loadFinished) self.url = "http://localhost:8081/" self.imgs_dir = imgs_dir if imgs_dir else time.asctime() self.create_dir(self.imgs_dir) self.size = QSize(1920, 1460) self.settings().setAttribute(QWebSettings.JavascriptEnabled, True)
def __init__(self, notesFolder, parent = None): QWebView.__init__(self, parent) self.insertDialog = InsertDialog(self) self.findReplaceDialog = FindReplaceDialog(self) self.notesFolder = notesFolder self.urlForCopy = None self.path = None self.makeHeaders() self.copySourceFilesToNotesFolder() self.installEventFilter(EditorFilter(self)) self.createActions()
def __init__(self, vertical, parent=None): QWebView.__init__(self, parent) self.vertical = vertical self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks) self.linkClicked.connect(self.link_activated) self._link_clicked = False self.setAttribute(Qt.WA_OpaquePaintEvent, False) palette = self.palette() self.setAcceptDrops(False) palette.setBrush(QPalette.Base, Qt.transparent) self.page().setPalette(palette) self.css = P('templates/book_details.css', data=True).decode('utf-8')
def __init__(self, window): QWebView.__init__(self) self.window = window with open(Resources.get_path("leftpane.js"), "r") as f: self.js = f.read() self.setFixedWidth(0) self.setVisible(False) # We don't want plugins for this simple pane self.settings().setAttribute(QWebSettings.PluginsEnabled, False) self.setUrl(QUrl.fromLocalFile(Resources.get_path("leftpane.html"))) self.page().currentFrame().addToJavaScriptWindowObject("leftPane", self) self.page().currentFrame().evaluateJavaScript(self.js)
def __init__(self, window): QWebView.__init__(self) self.window = window with open(get_resource_path("scudcloud.js"), "r") as f: self.js = f.read() QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True) QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True) QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.window.debug) self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) self.connect(self, SIGNAL("urlChanged(const QUrl&)"), self.urlChanged) self.connect(self, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked) self.addActions()
def __init__(self, parent): QWebView.__init__(self, parent) self._page = Page() self._page.elem_clicked.connect(self.elem_clicked) self.setPage(self._page) raw = ''' body { background-color: white } .calibre_toc_hover:hover { cursor: pointer !important; border-top: solid 5px green !important } ''' raw = '::selection {background:#ffff00; color:#000;}\n' + raw data = 'data:text/css;charset=utf-8;base64,' data += b64encode(raw.encode('utf-8')) self.settings().setUserStyleSheetUrl(QUrl(data))
def __init__(self, window): QWebView.__init__(self) self.window = window with open(Resources.get_path("leftpane.js"), "r") as f: self.js = f.read() self.setFixedWidth(0) self.setVisible(False) # We don't want plugins for this simple pane self.settings().setAttribute(QWebSettings.PluginsEnabled, False) self.setUrl(QUrl.fromLocalFile(Resources.get_path("leftpane.html"))) self.page().currentFrame().addToJavaScriptWindowObject( "leftPane", self) self.page().currentFrame().evaluateJavaScript(self.js)
def __init__(self, parent=None): QWebView.__init__(self, parent) self.webViews.append(self) self.setWindowTitle("Seabiscuit2") self.titleChanged.connect(self.setWindowTitle) self.iconChanged.connect(self.setWindowIcon) self.page().networkAccessManager().setCookieJar(self.cookieJar) self.cookieJar.setParent(None) self.settings().enablePersistentStorage(seabiscuit_home) self.settings().setAttribute(self.settings().PluginsEnabled, True) self.settings().setAttribute(self.settings().JavaEnabled, True) self.settings().setAttribute(self.settings().SpatialNavigationEnabled, True) self.settings().setAttribute(self.settings().DeveloperExtrasEnabled, True)
def __init__(self, window): self.configure_proxy() QWebView.__init__(self) self.window = window with open(Resources.get_path("scudcloud.js"), "r") as f: self.js = f.read() self.setZoomFactor(self.window.zoom) self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) self.connect(self, SIGNAL("urlChanged(const QUrl&)"), self.urlChanged) self.connect(self, SIGNAL("loadFinished(bool)"), self.loadFinished) self.connect(self, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked) self.addActions()
def __init__(self, parent=None): QWebView.__init__(self, parent) self.setAcceptDrops(False) self.setMaximumWidth(300) self.setMinimumWidth(300) palette = self.palette() palette.setBrush(QPalette.Base, Qt.transparent) self.page().setPalette(palette) self.setAttribute(Qt.WA_OpaquePaintEvent, False) self.page().setLinkDelegationPolicy(self.page().DelegateAllLinks) self.linkClicked.connect(self.link_clicked)
def __init__(self, parent): QWebView.__init__(self, parent) self._page = Page() self._page.elem_clicked.connect(self.elem_clicked) self.setPage(self._page) raw = ''' body { background-color: white } .calibre_toc_hover:hover { cursor: pointer !important; border-top: solid 5px green !important } ''' raw = '::selection {background:#ffff00; color:#000;}\n'+raw data = 'data:text/css;charset=utf-8;base64,' data += b64encode(raw.encode('utf-8')) self.settings().setUserStyleSheetUrl(QUrl(data))
def __init__(self, parent=None): QWebView.__init__(self, parent) self.setupUi(self) self.logger = getLogger('webview') page = WebPage(self) self.setPage(page) connect = self.connect connect(self.pageAction(page.Back), Signals.triggered, self.on_browseBack) connect(page.mainFrame(), Signals.javaScriptWindowObjectCleared, self.on_jswinClear)
def __init__(self, window): self.configure_proxy() QWebView.__init__(self) self.window = window with open(Resources.get_path("scudcloud.js"), "r") as f: self.js = f.read() self.setZoomFactor(self.window.zoom) self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) self.urlChanged.connect(self._urlChanged) self.loadStarted.connect(self._loadStarted) self.loadFinished.connect(self._loadFinished) self.linkClicked.connect(self._linkClicked) self.page().featurePermissionRequested.connect(self.permissionRequested) self.addActions()
def __init__(self, parent=None): QWebView.__init__(self, parent) page = WebPage() self.setPage(page) self._frame = self.page().mainFrame() self._rscDir = '%s/resources' % os.path.dirname( os.path.realpath(__file__)) f = open('%s/map.html' % self._rscDir, 'r') html = f.read() f.close() self.setHtml(html)
def __init__(self, base, column_id): QWebView.__init__(self) self.base = base self.column_id = column_id self.linkClicked.connect(self.__element_clicked) page = self.page() page.setLinkDelegationPolicy(QWebPage.DelegateAllLinks) page.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True) if not self.base.debug: self.setContextMenuPolicy(Qt.NoContextMenu) self.setPage(page) self.status_template = self.__load_template('status.html') self.stylesheet = self.__load_stylesheet() self.show()
def __init__(self, name): QWebView.__init__(self) self.setPage(PlotWebPage(name)) self.setRenderHint(QPainter.Antialiasing, True) self.setContextMenuPolicy(Qt.NoContextMenu) self.settings().setAttribute(QWebSettings.JavascriptEnabled, True) self.settings().setAttribute(QWebSettings.LocalContentCanAccessFileUrls, True) self.settings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True) self.settings().clearMemoryCaches() self.__inspector_window = None shortcut = QShortcut(self) shortcut.setKey(Qt.Key_F12) shortcut.activated.connect(self.toggleInspector)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) QWebView.__init__(self) self.ui = BrowserDialog() self.ui.setupUi(self) self.ui.lineEdit.returnPressed.connect(self.loadURL) def loadURL(self): url = self.ui.lineEdit.text() self.ui.qwebview.load(QUrl(url)) self.show() #self.ui.lineEdit.setText("") if __name__ == "__main__": app = QtGui.QApplication(sys.argv) myapp = MyBrowser() myapp.ui.qwebview.load(QUrl('http://www.pythonspot.com')) myapp.show() sys.exit(app.exec_())
def __init__(self, base_url=None, gui=False, user_agent=None, proxy=None, load_images=False, forbidden_extensions=None, allowed_regex='.*?', timeout=20, delay=5, enable_plugins=False): self.app = QApplication(sys.argv) # must instantiate first QWebView.__init__(self) manager = NetworkAccessManager(proxy, forbidden_extensions, allowed_regex) manager.finished.connect(self.finished) webpage = WebPage(user_agent or alg.rand_agent()) webpage.setNetworkAccessManager(manager) self.setPage(webpage) self.setHtml('<html><head></head><body>No content loaded</body></html>', QUrl('http://localhost')) self.timeout = timeout self.delay = delay self.base_url = base_url self.jquery_lib = None # enable flash plugin etc. self.settings().setAttribute(QWebSettings.PluginsEnabled, enable_plugins) self.settings().setAttribute(QWebSettings.JavaEnabled, enable_plugins) self.settings().setAttribute(QWebSettings.AutoLoadImages, load_images) self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True) if gui: self.show()
def __init__(self, mainWindow, parent=None): ''' Constructor ''' QWebView.__init__(self, parent) self.mainWindow = mainWindow self.setAcceptDrops(True) self._zoomIndex = self.DEFAULT_ZOOM_INDEX self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) # Disable the context menu if in a release environment if misc.is_release_environment(): def nothing(s, event): pass self.contextMenuEvent = nothing self.linkClicked.connect(self.myLinkClicked) self._keyboardNavEnabled = True
def __init__(self, name, app, scope, r_server, delay=1, proxy=None, forbidden_extensions=None, allowed_regex='.*?'): QWebView.__init__(self) self.name = name self.app = app self.scope = scope self.r_server = r_server self.delay = delay self.current_level = -1 self.async_res = [] self._t_pool = dict() LOGGER.debug("<%s> Initialized" % name) manager = NetworkAccessManager(proxy, forbidden_extensions, allowed_regex) manager.finished.connect(self._on_finished) webpage = WebPage( "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.94 Chrome/37.0.2062.94 Safari/537.36" ) webpage.setNetworkAccessManager(manager) #webpage.mainFrame().javaScriptWindowObjectCleared.connect(self._on_jsWinObjCleared) self.setHtml( '<html><head></head><body><h1>Multithreaded Crawler</h1><p>Waiting for orders, sir!</p></body></html>', QUrl('http://localhost')) self.setPage(webpage) self.loadFinished.connect(self._on_loadFinished) self.settings().setAttribute(QWebSettings.PluginsEnabled, True) self.settings().setAttribute(QWebSettings.JavaEnabled, True) self.settings().setAttribute(QWebSettings.AutoLoadImages, True) self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
def __init__(self): QWebView.__init__(self)