niklasb / dryscrape

[not actively maintained] A lightweight Python library that uses Webkit to enable easy scraping of dynamic, Javascript-heavy web pages
http://dryscrape.readthedocs.io/
MIT License
533 stars 67 forks source link

Ubuntu-Server 11.10 (NoX11Error) #5

Closed sframe closed 12 years ago

sframe commented 12 years ago

Hope to get this working on my Linux server, because it works a treat on my Mac.

Traceback (most recent call last):
  File "drydemo.py", line 6, in <module>
    sess = dryscrape.Session(base_url = 'http://google.com')
  File "/usr/local/lib/python2.7/dist-packages/dryscrape/session.py", line 18, in __init__
    self.driver = driver or DefaultDriver()
  File "/usr/local/lib/python2.7/dist-packages/dryscrape/driver/webkit.py", line 30, in __init__
    super(Driver, self).__init__(**kw)
  File "/usr/local/lib/python2.7/dist-packages/webkit_server.py", line 206, in __init__
    self.conn = connection or ServerConnection()
  File "/usr/local/lib/python2.7/dist-packages/webkit_server.py", line 418, in __init__
    self._sock = (server or get_default_server()).connect()
  File "/usr/local/lib/python2.7/dist-packages/webkit_server.py", line 397, in get_default_server
    default_server = Server()
  File "/usr/local/lib/python2.7/dist-packages/webkit_server.py", line 375, in __init__
    raise NoX11Error, "Cannot connect to X. You can try running with xvfb-run."
webkit_server.NoX11Error: Cannot connect to X. You can try running with xvfb-run.

Thanks!

niklasb commented 12 years ago

Well, it pretty much tells you what's wrong: You don't run it inside X (DISPLAY is not set, probably because this is a headless server). It also tells you what you can do: sudo apt-get install xvfb and run the example with xvfb-run python drydemo.py.

sframe commented 12 years ago

Thanks for the tip on running xvfb-run. I had no idea that existed nor how to invoke it.

niklasb commented 12 years ago

@sframe: That's why I included that tip into the error message ;) Have a look at man xvfb-run for more information.