2

I am running a fresh install of Anaconda “Python 3.7.1 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Windows 10 | Spyder 3.3.2” and have not had luck porting Youtube Sentdex "Dynamic Javascript Scraping - Web scraping with Beautiful Soup 4 p.4" example to PyQt5. Can you assist? Many thanks!

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)
        QWebEnginePage.__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)
# output should be "Look at you shinin!"
Gene44
  • 41
  • 3

0 Answers0