久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='xDNmD'><style id='xDNmD'><dir id='xDNmD'><q id='xDNmD'></q></dir></style></legend>

      1. <i id='xDNmD'><tr id='xDNmD'><dt id='xDNmD'><q id='xDNmD'><span id='xDNmD'><b id='xDNmD'><form id='xDNmD'><ins id='xDNmD'></ins><ul id='xDNmD'></ul><sub id='xDNmD'></sub></form><legend id='xDNmD'></legend><bdo id='xDNmD'><pre id='xDNmD'><center id='xDNmD'></center></pre></bdo></b><th id='xDNmD'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xDNmD'><tfoot id='xDNmD'></tfoot><dl id='xDNmD'><fieldset id='xDNmD'></fieldset></dl></div>
      2. <small id='xDNmD'></small><noframes id='xDNmD'>

        • <bdo id='xDNmD'></bdo><ul id='xDNmD'></ul>
        <tfoot id='xDNmD'></tfoot>

        PyQt4 到 PyQt5 ->mainFrame() 已棄用,需要修復才能

        PyQt4 to PyQt5 -gt; mainFrame() deprecated, need fix to load web pages(PyQt4 到 PyQt5 -mainFrame() 已棄用,需要修復才能加載網頁)
      3. <tfoot id='GhS7j'></tfoot>
        1. <i id='GhS7j'><tr id='GhS7j'><dt id='GhS7j'><q id='GhS7j'><span id='GhS7j'><b id='GhS7j'><form id='GhS7j'><ins id='GhS7j'></ins><ul id='GhS7j'></ul><sub id='GhS7j'></sub></form><legend id='GhS7j'></legend><bdo id='GhS7j'><pre id='GhS7j'><center id='GhS7j'></center></pre></bdo></b><th id='GhS7j'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GhS7j'><tfoot id='GhS7j'></tfoot><dl id='GhS7j'><fieldset id='GhS7j'></fieldset></dl></div>
        2. <legend id='GhS7j'><style id='GhS7j'><dir id='GhS7j'><q id='GhS7j'></q></dir></style></legend>

                  <tbody id='GhS7j'></tbody>
                  <bdo id='GhS7j'></bdo><ul id='GhS7j'></ul>

                  <small id='GhS7j'></small><noframes id='GhS7j'>

                • 本文介紹了PyQt4 到 PyQt5 ->mainFrame() 已棄用,需要修復才能加載網頁的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在學習 Sentdex 的 PyQt4 YouTube 教程

                  現在我正在嘗試使用 PyQt5 編寫相同的應用程序,這就是我所擁有的:

                  導入操作系統導入系統從 PyQt5.QtWidgets 導入 QApplication從 PyQt5.QtCore 導入 QUrl,QEventLoop從 PyQt5.QtWebEngineWidgets 導入 QWebEnginePage從 bs4 導入 BeautifulSoup導入請求類客戶端(QWebEnginePage):def __init__(self, url):self.app = QApplication(sys.argv)QWebEnginePage.__init__(self)self.loadFinished.connect(self._loadFinished)self.load(QUrl(url))self.app.exec_()def _loadFinished(self):self.app.quit()url = 'https://pythonprogramming.net/parsememcparseface/'client_response = 客戶端(網址)#我認為問題出在第 26 行源 = client_response.mainFrame().toHtml()湯= BeautifulSoup(來源,html.parser")js_test = soup.find('p', class_='jstest')打印(js_test.text)

                  當我運行它時,我收到消息:

                  <塊引用>

                  source = client_response.mainFrame().toHtml()AttributeError:客戶端"對象沒有屬性主框架"

                  我嘗試了幾種不同的解決方案,但都沒有奏效.任何幫助將不勝感激.

                  編輯

                  在第 15 行記錄 QUrl(url) 返回此值:

                  <塊引用>

                  PyQt5.QtCore.QUrl('https://pythonprogramming.net/parsememcparseface/')

                  當我為第 26 行嘗試 source = client_response.load(QUrl(url)) 時,我最終得到以下消息:

                  <塊引用>

                  文件test3.py",第 28 行,在 <module>湯= BeautifulSoup(來源,html.parser")文件/Users/MYNAME/.venv/qtproject/lib/python3.6/site-packages/bs4/__init__.py",第 192 行,在 __init__elif len(標記) <= 256 和 (TypeError:NoneType"類型的對象沒有 len()

                  當我嘗試 source = client_response.url() 我得到:

                  <塊引用>

                  soup = BeautifulSoup(source, "html.parser")文件/Users/MYNAME/.venv/qtproject/lib/python3.6/site-packages/bs4/__init__.py",第 192 行,在 __init__elif len(標記) <= 256 和 (TypeError:QUrl"類型的對象沒有 len()

                  解決方案

                  你必須在類的定義中調用QWebEnginePage::toHtml().QWebEnginePage::toHtml() 接受一個指針函數或一個 lambda 作為參數,而這個指針函數又必須接受一個 'str' 類型的參數(這是包含頁面 html 的參數).下面是示例代碼.

                  將 bs4 導入為 bs導入系統導入 urllib.request從 PyQt5.QtWebEngineWidgets 導入 QWebEnginePage從 PyQt5.QtWidgets 導入 QApplication從 PyQt5.QtCore 導入 QUrl類頁面(QWebEnginePage):def __init__(self, url):self.app = QApplication(sys.argv)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('加載完成')def 可調用(自我,html_str):self.html = html_strself.app.quit()定義主():page = Page('https://pythonprogramming.net/parsememcparseface/')湯 = bs.BeautifulSoup(page.html, 'html.parser')js_test = soup.find('p', class_='jstest')打印 js_test.text如果 __name__ == '__main__': main()

                  I'm doing Sentdex's PyQt4 YouTube tutorial right here. I'm trying to follow along but use PyQt5 instead. It's a simple web scraping app. I followed along with Sentdex's tutorial and I got here:

                  Now I'm trying to write the same application with PyQt5 and this is what I have:

                  import os
                  import sys
                  from PyQt5.QtWidgets import QApplication
                  from PyQt5.QtCore import QUrl, QEventLoop
                  from PyQt5.QtWebEngineWidgets import QWebEnginePage
                  from bs4 import BeautifulSoup
                  import requests
                  
                  
                  class Client(QWebEnginePage):
                      def __init__(self, url):
                          self.app = QApplication(sys.argv)
                          QWebEnginePage.__init__(self)
                          self.loadFinished.connect(self._loadFinished)
                          self.load(QUrl(url))
                          self.app.exec_()
                  
                      def _loadFinished(self):
                          self.app.quit()
                  
                  
                  url = 'https://pythonprogramming.net/parsememcparseface/'
                  client_response = Client(url)
                  
                  #I think the issue is here at LINE 26
                  source = client_response.mainFrame().toHtml()
                  
                  soup = BeautifulSoup(source, "html.parser")
                  js_test = soup.find('p', class_='jstest')
                  print(js_test.text)
                  

                  When I run this, I get the message:

                  source = client_response.mainFrame().toHtml()
                  AttributeError: 'Client' object has no attribute 'mainFrame'
                  

                  I've tried a few different solutions but none work. Any help would be appreciated.

                  EDIT

                  Logging QUrl(url) on line 15 returns this value:

                  PyQt5.QtCore.QUrl('https://pythonprogramming.net/parsememcparseface/')

                  When I try source = client_response.load(QUrl(url)) for line 26, I end up with the message:

                  File "test3.py", line 28, in <module> soup = BeautifulSoup(source, "html.parser") File "/Users/MYNAME/.venv/qtproject/lib/python3.6/site-packages/bs4/__init__.py", line 192, in __init__ elif len(markup) <= 256 and ( TypeError: object of type 'NoneType' has no len()

                  When I try source = client_response.url() I get:

                  soup = BeautifulSoup(source, "html.parser")
                        File "/Users/MYNAME/.venv/qtproject/lib/python3.6/site-packages/bs4/__init__.py", line 192, in __init__
                          elif len(markup) <= 256 and (
                      TypeError: object of type 'QUrl' has no len()
                  

                  解決方案

                  you must call the QWebEnginePage::toHtml() inside the definition of the class. QWebEnginePage::toHtml() takes a pointer function or a lambda as a parameter, and this pointer function must in turn take a parameter of 'str' type (this is the parameter that contains the page's html). Here is sample code below.

                  import bs4 as bs
                  import sys
                  import urllib.request
                  from PyQt5.QtWebEngineWidgets import QWebEnginePage
                  from PyQt5.QtWidgets import QApplication
                  from PyQt5.QtCore import QUrl
                  
                  class Page(QWebEnginePage):
                      def __init__(self, url):
                          self.app = QApplication(sys.argv)
                          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('Load finished')
                  
                      def Callable(self, html_str):
                          self.html = html_str
                          self.app.quit()
                  
                  
                  def main():
                      page = Page('https://pythonprogramming.net/parsememcparseface/')
                      soup = bs.BeautifulSoup(page.html, 'html.parser')
                      js_test = soup.find('p', class_='jstest')
                      print js_test.text
                  
                  if __name__ == '__main__': main()
                  

                  這篇關于PyQt4 到 PyQt5 ->mainFrame() 已棄用,需要修復才能加載網頁的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                  <i id='Rs9V4'><tr id='Rs9V4'><dt id='Rs9V4'><q id='Rs9V4'><span id='Rs9V4'><b id='Rs9V4'><form id='Rs9V4'><ins id='Rs9V4'></ins><ul id='Rs9V4'></ul><sub id='Rs9V4'></sub></form><legend id='Rs9V4'></legend><bdo id='Rs9V4'><pre id='Rs9V4'><center id='Rs9V4'></center></pre></bdo></b><th id='Rs9V4'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Rs9V4'><tfoot id='Rs9V4'></tfoot><dl id='Rs9V4'><fieldset id='Rs9V4'></fieldset></dl></div>

                    <bdo id='Rs9V4'></bdo><ul id='Rs9V4'></ul>
                  • <tfoot id='Rs9V4'></tfoot>

                      • <legend id='Rs9V4'><style id='Rs9V4'><dir id='Rs9V4'><q id='Rs9V4'></q></dir></style></legend>

                        <small id='Rs9V4'></small><noframes id='Rs9V4'>

                          <tbody id='Rs9V4'></tbody>

                            主站蜘蛛池模板: av手机免费在线观看 | 超碰在线影院 | 福利视频二区 | 韩日一区二区 | 国产一区二区三区久久久久久久久 | 精品乱码一区二区三四区视频 | 亚洲综合五月天婷婷 | 欧美一区在线视频 | 国产成人福利视频在线观看 | 欧美a在线 | 精品无码久久久久国产 | 久久国产精品色av免费观看 | 久久久高清 | 成人亚洲| 精品欧美一区二区在线观看视频 | 国产资源视频 | 美女一级毛片 | 精品免费国产视频 | 国产分类视频 | www.久久久久久久久久久 | 国产精品视频免费观看 | 精品国产一级片 | 日本三级线观看 视频 | 亚洲成人av一区二区 | 狠狠狠| 日韩午夜电影在线观看 | 在线观看国产91 | h片在线观看网站 | 在线观看成人av | 国产一区在线视频 | 日韩av福利在线观看 | 国产免费播放视频 | 日韩一区二区在线视频 | 成人妇女免费播放久久久 | 亚洲精品乱码8久久久久久日本 | 中文字幕精品一区二区三区精品 | 国产精品久久久久久福利一牛影视 | 在线视频h| 久久精品 | 婷婷开心激情综合五月天 | 欧美色综合一区二区三区 |