【发布时间】:2017-07-09 14:24:20
【问题描述】:
我正在尝试使用 Ghost.py 在网页上填写表格。目前我正在努力解决正确的表单字段,css选择器让我头疼。所以我决定让 Ghost.py 完成这项工作并给我一个包含表单字段和标识符的列表。到目前为止,我已经尝试过:
import ghost
g = ghost.Ghost()
with g.start(display=True) as session:
page, extra_resources = session.open("http://www.surfbirds.com/identifier/what-british-bird.htm")
if page.http_status == 200 and \
'Head characters' in page.content:
print("got it!")
ressources =
session.evaluate('document.getElementByName("geog");')
print("ressources: {}".format(ressources))
这会引发错误:
Ghost<f836191b-16e6-4a0d-b2c5-96d657556b46>: undefined(0): TypeError:
'undefined' is not a function
ressources: (None, [])
我不知道是什么原因造成的,有人可以指出我应该看的方向吗?
【问题讨论】:
-
谢谢赫伯特,这消除了错误消息,但不仅返回了“geog”中的元素,还返回了此页面中的每个表单。尽管如此,排除了错误,我会将这个问题标记为已关闭。并寻找关于 jquery 语法的好教程。
标签: javascript python web-scraping ghost.py