我正在尝试用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, [])我不知道这是什么原因,有人能告诉我应该往哪里看吗?
发布于 2017-07-10 03:11:48
该页面上没有名为<geog>的标记。您可能希望查询名为geog的表单元素
document.querySelector('form[name=geog]')https://stackoverflow.com/questions/44997413
复制相似问题