I have Debian Linux server that I use for a variety of things. I want it to be able to do some web-scraping jobs I need done regularly.
This code can be found here.
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
def __init__(self, url):
self.app = QApplication(sys.argv, False) # Line updated based on mata's answer
def _loadFinished(self, result):
self.frame = self.mainFrame()
url = 'http://example.com'
: cannot connect to X server
One of the constructors of
QApplication takes a boolean argument
If you use that, you can instantiante QAppliaction without an X server, but you can't create QWidgets.
So in this case the only option is to use a virtual X server like Xvfb to render the GUI.
Xvfb can be installed and run using these commands (assuming you have apt-get installed). The code in the original question is in a file called
sudo apt-get install xvfb xvfb-run python render.py