久久久久久久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>

                            主站蜘蛛池模板: 一区中文字幕 | 黄色免费网址大全 | 91xxx在线观看| 欧美一区二区三区四区视频 | 91在线网站 | 亚洲国产精品久久久久婷婷老年 | 欧一区| 国产成人在线播放 | 日韩中文一区二区三区 | 成人在线视频免费观看 | 国产高清美女一级a毛片久久w | 久久久精品国产 | 亚洲网站在线播放 | 亚洲国产精品福利 | 亚洲在线一区 | 奇米久久 | 毛色毛片免费看 | 超碰在线播 | 97国产精品 | 日韩国产一区二区三区 | 成人天堂 | 欧美日韩中文字幕在线 | 国产一区二区三区免费观看视频 | 国产精品成人av | 亚洲一区二区在线 | 欧美成人精品一区二区男人看 | 午夜码电影 | 成人在线免费网站 | 日韩一级不卡 | a亚洲精品| 国产网站在线播放 | 夜夜久久| 免费观看黄网站 | 毛片大全 | 国产一区亚洲二区三区 | а_天堂中文最新版地址 | 日本在线看片 | 99草免费视频 | 国产一区精品在线 | 久久成人高清视频 | 亚洲成人精品国产 |