1

I am trying to get dynamic js content using python, beautifulsoup and PYQT4. The code I am using is given below

class Client(QWebPage):

 def __init__(self,url):
    self.app = QApplication(sys.argv)
    QWebPage.__init__(self)
    self.loadFinished.connect(self.on_page_load)
    print("test3")

    self.app.exec_()
    print("test4")

 def on_page_load(self):
    self.app.quit()

 url="https://pythonprogramming.net/parsememcparseface/"
 print("test1")

 client_response=Client(url)
 source=client_response.mainFrame().toHtml()
 print("test2")
 soup=  bs.BeautifulSoup(source,'html.parser')
 js_test=soup.find('p', class_='jstest')
 print(js_test.text)

The test 1 ,2 and 3 will get printed but not test 4.The program is getting stuck at line : self.app.exec_()

Tony Toms
  • 11
  • 2

0 Answers0