Guest User

source_PyQy5.py

a guest
Jan 28th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #Get source with scripts run using PyQt5
  3.  
  4. import sys
  5. import signal
  6.  
  7. from PyQt5.QtCore import Qt, QUrl
  8. from PyQt5.QtWidgets import QApplication
  9. from PyQt5.QtWebKitWidgets import QWebPage
  10.  
  11. agent = 'Mozilla/5.0 (Windows NT 6.2; x86_64; rv:48.0) Gecko/20100101 Firefox/50.0'
  12.  
  13. class Source_W_Scripts(QWebPage):
  14.     def __init__(self, url, file):
  15.         QWebPage.__init__(self)
  16.         self._url = url
  17.         self._file = file
  18.        
  19.     def userAgentForUrl(self, Qurl):
  20.         return (agent)
  21.  
  22.     def get_it(self):
  23.         signal.signal(signal.SIGINT, signal.SIG_DFL)
  24.         self.loadFinished.connect(self.finished_loading)
  25.         self.mainFrame().load(QUrl(self._url))
  26.  
  27.     def finished_loading( self, result ):
  28.         with open(self._file, 'w') as f:
  29.             f.write(self.mainFrame().toHtml())
  30.         sys.exit(0)
  31.  
  32. def main():
  33.     url = input('Enter/Paste url for source: ')
  34.     out_file = input('Enter output file name: ')
  35.     app = QApplication([]) #(sys.argv)
  36.     dloader = Source_W_Scripts(url, out_file)
  37.     dloader.get_it()
  38.     sys.exit(app.exec_())
  39.  
  40. if __name__ == '__main__':
  41.     main()
Add Comment
Please, Sign In to add comment