我已经成功地将dryscrape
以及pythoneverywhere.com中的一些并发软件包(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
出了什么问题?
答案 0 :(得分:1)
尝试:
dryscrape.start_xvfb #then create session
或者:
import xvfbwrapper as x
x.Xvfb().start()
答案 1 :(得分:0)