有没有办法将BeautifulSoup(或类似的网页抓取工具)导入monkeyrunner?
导入BeautifulSoup到Python程序成功。但是,我在导入到 Monkeyrunner 时遇到了 importError
ImportError: No module named bs4
经过一番挖掘,我附加了 BeautifulSoup 路径名
import sys
sys.path.append("path/to/monkeyrunner/directory/the_filename.egg") sys.path.append("path/to/monekeyrunner/directory")
这使得 Monkeyrunner 能够正确地看到 BeautifulSoup 的目录。然而,提示BeautifulSoup中的一些东西;见下文:
from bs4 import BeautifulSoup
SyntaxError: ("no viable alternative at input '' ''", ('C:\\Python27\\lib\\site-
packages\\bs4\\__init__.py', 186, 56, " if ((isinstance(markup, b
ytes) and not b' ' in markup)\n"))
再次,导入python没有错误。关于为什么 Monkeyrunner 会出现这种情况,有什么建议吗?
最佳答案
您可以尝试AndroidViewClient/culebra这是 100% python。它将为您提供 monkeyrunner
中的几乎所有功能以及更多功能。
bs4
可以毫无问题地导入到您的脚本中。
关于python - 将 BeautifulSoup 导入 Monkeyrunner,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29148198/