0

我正在尝试使用 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, [])

我不知道是什么原因造成的,有人可以指出我应该看的方向吗?

4

1 回答 1

0

该页面上没有名为 的标签<geog>。您可能想查询带有 name 的表单元素geog

document.querySelector('form[name=geog]')
于 2017-07-09T19:11:48.077 回答