joelnazarene

pyqtieee

Mar 24th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.58 KB | None | 0 0
  1. import bs4
  2. from urllib import urlopen as uReq
  3. from bs4 import BeautifulSoup as soup
  4. myurl="https://ieeexplore.ieee.org/search/searchresult.jsp?newsearch=true&queryText=web%20scraping"
  5. a="jesus"
  6. #b=raw_input('enter the keyword \n\n')
  7. #myurl=myurl+b
  8.  
  9. uClient=uReq(myurl)
  10. pagehtml=uClient.read()
  11. uClient.close()
  12. pagesoup=soup(pagehtml,"html.parser")
  13. #containers=pagesoup.findAll("div",{"class":"main-section"})
  14. #
  15. #print(pagesoup.body)
  16. containers=pagesoup.find_all('div')
  17.  
  18. #print(containers[21])
  19.  
  20.  
  21. i=0
  22.  
  23. for container in containers :
  24.     i=i+1
  25.     print("\n\nthe container count is \n\n")
  26.     print(i)
  27.     print(container)
  28. =============================================================================================================
  29.  
  30. import sys
  31. from PyQt4.QtGui import QApplication
  32. from PyQt4.QtCore import QUrl
  33. from PyQt4.QtWebKit import QWebPage
  34. import bs4 as bs
  35. import urllib
  36.  
  37.  
  38. class Client(QWebPage):
  39.     def __init__(self,url):
  40.         self.app = QApplication(sys.argv)
  41.         QWebPage.__init__(self)
  42.         self.loadFinished.connect(self.on_page_load)
  43.         self.mainFrame().load(QUrl(url))
  44.         self.app.exec_()
  45.      
  46.      
  47.     def on_page_load(self):
  48.         self.app.quit()
  49.        
  50.        
  51.        
  52.        
  53. url='https://pythonprogramming.net/parsememcparseface/'
  54. client_response = Client(url)
  55. source = client_response.mainFrame().toHtml()
  56. soup = bs.BeautifulSoup(source,'lxml')
  57. js_test = soup.find('p', class_='jstest')
  58. print(js_test.text)
  59.        
  60.        
  61. =============================================================================
Add Comment
Please, Sign In to add comment