我已经在 pythonanywhere.com 上安装了 dryscrape。然而 session var 无法加载任何站点,为什么?
import dryscrape
# as in demo: http://dryscrape.readthedocs.io/en/latest/usage.html#first-demonstration
dryscrape.start_xvfb()
sess = dryscrape.Session()
sess.visit('https://www.pythonanywhere.com/')
结果错误:
sess.visit('https://www.pythonanywhere.com/')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/igorsavinkin/.local/lib/python3.5/site-packages/dryscrape/session.py", line 33, in visit
return self.driver.visit(self.complete_url(url))
File "/home/igorsavinkin/.local/lib/python3.5/site-packages/webkit_server.py", line 235, in visit
self.conn.issue_command("Visit", url)
File "/home/igorsavinkin/.local/lib/python3.5/site-packages/webkit_server.py", line 520, in issue_command
return self._read_response()
File "/home/igorsavinkin/.local/lib/python3.5/site-packages/webkit_server.py", line 530, in _read_response
raise InvalidResponseError(msg)
webkit_server.InvalidResponseError: {"class":"InvalidResponseError","message":"Unable to load URL: https://www.pythonanywhere.com/ because
of error loading https://www.pythonanywhere.com/: Unknown error"}
无论我从白名单中访问哪个站点,问题都是一样的。
我读过有关dryscrape安装先决条件的信息:
在安装dryscrape之前,您需要安装一些它所依赖的软件:
- Qt, QtWebKit
- lxml
- 点子
- xvfb_(仅当没有其他 X 服务器可用时才需要)
因此,pythoneverywhere 的默认模块既不是Qt
也不是...QtWebKit
当我尝试安装它时,结果是一个错误(与 相同QtWebKit
)
$ pip install --user Qt
Collecting Qt
Could not find a version that satisfies the requirement Qt (from versions: )
No matching distribution found for Qt
干刮设置文件 setup.py:
from distutils.core import setup, Command
setup(name='dryscrape',
version='0.9.1',
description='a lightweight Javascript-aware, headless web scraping library for Python',
author='Niklas Baumstark',
author_email='niklas.baumstark@gmail.com',
license='MIT',
url='https://niklasb.github.com/dryscrape',
packages=['dryscrape', 'dryscrape.driver'],
requires=['webkit_server', 'lxml'],
)
任何帮助都是可观的......