python - 将 BeautifulSoup 导入 Monkeyrunner

标签 python beautifulsoup monkeyrunner

有没有办法将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/

相关文章:

android - 是否可以在 adb logcat 中清除指定的消息或行而不是全部清除?

python - 使用 Jinja 过滤器创建内容片段

Python BeautifulSoup - 获取 Div Select Option 中的值

php - 如何从 Yii 网页和 Python 执行 MonkeyRunner

Python 'different_locale' 错误的区域设置转换

python - 从抓取的 HTML 数据写入 CSV

android - Android monkeyrunner 的 help.py 在哪里

python - 使用字典将表情符号替换为文本

javascript - Django 中的不同角色 : show different content in web page

python 3 正则表达式模式替换