本文整理汇总了Python中PySide.QtWebKit.QWebView.stop方法的典型用法代码示例。如果您正苦于以下问题:Python QWebView.stop方法的具体用法?Python QWebView.stop怎么用?Python QWebView.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtWebKit.QWebView
的用法示例。
在下文中一共展示了QWebView.stop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Browser
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import stop [as 别名]
#.........这里部分代码省略.........
# to avoid treating the request by the driver as successful
ok = False
elif len(pending_requests) > 0:
self.logger.info("loadFinished emitted, waiting for requests:"
" {0}".format(pending_requests))
loaded = partial(lambda x: self._load_finished(x), ok)
QTimer.singleShot(1000, loaded)
return
self.logger.info('loadFinshed emitted, returning result.')
frame = self._web_view.page().mainFrame()
url = smart_str(frame.url().toString())
html = frame.toHtml()
result = {'html': html,
'url': url,
'successful': ok}
if self._network_manager.errors:
result['errors'] = self._network_manager.errors
self._finish_task(result)
def _start_task(self):
self._is_task_finished = False
# abusing the ok param of loadFinished
timed_out = lambda: self._load_finished('timed_out')
self._timeout_timer = QTimer()
self._timeout_timer.timeout.connect(timed_out)
self._timeout_timer.start(self._timeout)
def _finish_task(self, result):
self._is_task_finished = True
self._timeout_timer.stop()
# calling the callback function which we passed upon instantiation to
# report the results there
self._result_callback(result)
def make(self, method, url, headers, raw_data=None):
request = self._prepare_request(url, headers)
operation = self._request_ops[method.lower()]
request_data = self._urlencode_request_data(raw_data or dict())
self._start_task()
self._web_view.load(request, operation, request_data)
def _find_element(self, selector):
main_frame = self._web_page.mainFrame()
element = main_frame.findFirstElement(selector)
if element.isNull():
raise ElementNotFound(selector)
return element
def fill_input(self, selector, value):
js_fill_input = """
this.setAttribute("value", "{0}");
this.value = "{0}";
""".format(value)
element = self._find_element(selector)
element.evaluateJavaScript(js_fill_input)
def click(self, selector):
element = self._find_element(selector)
offset = element.geometry()