0

我已经成功地在 pythoneverywhere.com 中安装dryscrape了一些随附的包 ( )。webkit-server xvfbwrapper

13:45 / $ pip3.5 install --user dryscrape
Collecting dryscrape
  Using cached dryscrape-1.0.tar.gz
Collecting webkit_server>=1.0 (from dryscrape)
  Using cached webkit-server-1.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): lxml in /usr/local/lib/python3.5/dist-packages (from dryscrape)
Collecting xvfbwrapper (from dryscrape)
  Using cached xvfbwrapper-0.2.8.tar.gz
Building wheels for collected packages: dryscrape, webkit-server, xvfbwrapper
  Running setup.py bdist_wheel for dryscrape ... done
  Stored in directory: /home/igorsavinkin/.cache/pip/wheels/f2/76/aa/8e6b197ff296ec63ac7677880040011f05114eb7a76334ef66
  Running setup.py bdist_wheel for webkit-server ... done
  Stored in directory: /home/igorsavinkin/.cache/pip/wheels/a1/d5/20/88fcbe54d8c712563f2a7bd0a57a0743743210ee6d9b724d62
  Running setup.py bdist_wheel for xvfbwrapper ... done
  Stored in directory: /home/igorsavinkin/.cache/pip/wheels/5e/03/bc/8fe7ce36b7a38c20d40e49b4f1b46a7e0f2a164ba36f1ed4f6
Successfully built dryscrape webkit-server xvfbwrapper
Installing collected packages: webkit-server, xvfbwrapper, dryscrape
Successfully installed dryscrape webkit-server xvfbwrapper

但是,我仍然无法使用会话运行它:

import dryscrape
from bs4 import BeautifulSoup
sess = dryscrape.session.Session()

返回此错误

Traceback (most recent call last):
  File "/home/igorsavinkin/.local/lib/python3.5/site-packages/webkit_server.py", line 420, in __init__
    self._port = int(re.search(b"port: (\d+)", output).group(1))
AttributeError: 'NoneType' object has no attribute 'group'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/igorsavinkin/.local/lib/python3.5/site-packages/dryscrape/session.py", line 22, in __init__
    self.driver = driver or DefaultDriver()
  File "/home/igorsavinkin/.local/lib/python3.5/site-packages/dryscrape/driver/webkit.py", line 30, in __init__
    super(Driver, self).__init__(**kw)
  File "/home/igorsavinkin/.local/lib/python3.5/site-packages/webkit_server.py", line 230, in __init__
    self.conn = connection or ServerConnection()
  File "/home/igorsavinkin/.local/lib/python3.5/site-packages/webkit_server.py", line 507, in __init__
    self._sock = (server or get_default_server()).connect()
  File "/home/igorsavinkin/.local/lib/python3.5/site-packages/webkit_server.py", line 450, in get_default_server
    _default_server = Server()
  File "/home/igorsavinkin/.local/lib/python3.5/site-packages/webkit_server.py", line 427, in __init__
    raise WebkitServerError("webkit-server failed to start. Output:\n" + err)
webkit_server.WebkitServerError: webkit-server failed to start. Output:
webkit_server: cannot connect to X server 

怎么了?

4

2 回答 2

1

尝试:

dryscrape.start_xvfb #then create session

或者:

import xvfbwrapper as x
x.Xvfb().start()
于 2017-09-20T05:30:37.940 回答
0

您没有安装 X11,它是一个窗口系统。

http://dryscrape.readthedocs.io/en/latest/apidoc.html#webkit_server.NoX11Error

于 2016-11-10T15:28:32.180 回答