Guest User

source_PyQt4.py

a guest
Jan 28th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. !/usr/bin/env python
  2. #Get source with scripts run using PyQt4
  3.  
  4. import sys
  5. import signal
  6.  
  7. from PyQt4.QtCore import *
  8. from PyQt4.QtGui import QApplication
  9. from PyQt4.QtWebKit 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.connect(self, SIGNAL('loadFinished(bool)'),
  25.                                         self.finished_loading)
  26.         self.mainFrame().load(QUrl(self._url))
  27.  
  28.     def finished_loading( self, result ):
  29.         with open(self._file, 'w') as f:
  30.             f.write(self.mainFrame().toHtml())
  31.         sys.exit(0)
  32.  
  33. def main():
  34.     url = input('Enter/Paste url for source: ')
  35.     out_file = input('Enter output file name: ')
  36.     app = QApplication([]) #(sys.argv)
  37.     dloader = Source_W_Scripts(url, out_file)
  38.     dloader.get_it()
  39.     sys.exit(app.exec_())
  40.  
  41. if __name__ == '__main__':
  42.     main()
Add Comment
Please, Sign In to add comment