The code below works fine except one thing, it does not follow the sign-up link. However if I go to my actual browser and in console type:
document.getElementById("link-signup").click()
It will redirect me to the desired page. I was thinking that the problem accured because I didn't enable some feature in settings. but I'm not sure.
Thank's for any help
#! /usr/bin/env python2.7
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
import sys
class GrabberSettings(QWebPage):
def __init__(self):
QWebPage.__init__(self)
self.settings().setAttribute(QWebSettings.AutoLoadImages, False)
class Grabber(QWebView):
def __init__(self):
QWebView.__init__(self)
self.setPage(GrabberSettings())
self.loadFinished.connect(self._loadComplete)
self.doc = self.page().mainFrame().documentElement()
def _loadComplete(self):
print "Done"
link = self.doc.findFirst('a[link-signup]')
if link:
print "link found"
link.evaluateJavaScript('click()')
if __name__ == "__main__":
app = QApplication(sys.argv)
view = Grabber()
gmail = QUrl('https://accounts.google.com')
view.load(gmail)
view.show()
app.exec_()