Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import sys
- import time
- from PyQt4.QtCore import *
- from PyQt4.QtGui import *
- from PyQt4.QtWebKit import *
- s = requests.session()
- login_data = dict(username='bybo', password='118932')
- s.post('https://rstforums.com/forum/login', data=login_data)
- class Screenshot(QWebView):
- def __init__(self):
- self.app = QApplication(sys.argv)
- QWebView.__init__(self)
- self._loaded = False
- self.loadFinished.connect(self._loadFinished)
- def capture(self, url, output_file):
- self.load(QUrl(url))
- self.wait_load()
- # set to webpage size
- frame = self.page().mainFrame()
- self.page().setViewportSize(frame.contentsSize())
- # render image
- image = QImage(self.page().viewportSize(), QImage.Format_ARGB32)
- painter = QPainter(image)
- frame.render(painter)
- painter.end()
- print 'Saving...', output_file
- image.save(output_file)
- def wait_load(self, delay=0):
- # process app events until page loaded
- while not self._loaded:
- self.app.processEvents()
- time.sleep(delay)
- self._loaded = False
- def _loadFinished(self, result):
- self._loaded = True
- s = Screenshot()
- ww = raw_input("Link-ul la care sa faci screen tarane: ")
- s.capture(ww, 'website.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement