Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python3动态内容web抓取_Python_Python 3.x_Web Scraping_Pyqt4 - Fatal编程技术网

使用python3动态内容web抓取

使用python3动态内容web抓取,python,python-3.x,web-scraping,pyqt4,Python,Python 3.x,Web Scraping,Pyqt4,如果我运行低于代码得到低于错误。你能帮我解决这些问题吗 Traceback (most recent call last): File "dynamic.py", line 20, in <module> client_response = Client(url) TypeError: QWebPage(QObject parent=None): argument 1 has unexpected type 'str' 修改: 这是你的真实代码吗?它应该是\uuuu i

如果我运行低于代码得到低于错误。你能帮我解决这些问题吗

Traceback (most recent call last):
  File "dynamic.py", line 20, in <module>
    client_response = Client(url)
TypeError: QWebPage(QObject parent=None): argument 1 has unexpected type 'str'
修改:


这是你的真实代码吗?它应该是
\uuuu init\uuuuu
而不是
\uu init\uuu
,您的原始函数名为
\uu int\uuuu
,您是否也将其重命名为
\uuu init\uuuuuu
?是的,我修改了。
QWebPage.\uu init(self)
应该是
QWebPage.\uu init\uuuuuuuuuuuuu(self)
修改后的代码我添加了。请检查并找出问题所在。
import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QUrl
from PyQt4.QtWebKit import QWebPage
import bs4 as bs


class Client(QWebPage):
    def _int_(self, url):
        self.app = QApplication(sys.argv)
        QWebPage._init_(self)
        self.loadFinished.connect(self.on_page_load)
        self.mainFrame().load(QUrl(url))
        self.app.exec_()
    def on_page_load(self):
        self.app.quit()

url = "https://pythonprogramming.net/parsememcparseface/"
client_response = Client(url)
source = client_response.mainFrame().toHtml()
soup = bs.BeautifulSoup(source, 'lxml')
js_test = soup.find('p', class_='jstest')
print(js_test.text)
import sys
from PyQt4.QtGui import QApplication
from PyQt4.QtCore import QUrl
from PyQt4.QtWebKit import QWebPage
import bs4 as bs


class Client(QWebPage):
    def __init__(self, url):
        self.app = QApplication(sys.argv)
        QWebPage.__init__(self)
        self.loadFinished.connect(self.on_page_load)
        self.mainFrame().load(QUrl(url))
        self.app.exec_()
    def on_page_load(self):
        self.app.quit()

url = "https://pythonprogramming.net/parsememcparseface/"
client_response = Client(url)
source = client_response.mainFrame().toHtml()
soup = bs.BeautifulSoup(source, 'lxml')
js_test = soup.find('p', class_='jstest')
print(js_test.text)