我试图用 Ghost.py 多次填写表格,我需要输入到表格中的值在一个列表中,程序如下所示:
inputData = ["input1", "input2", "andSoOn"]
ghost = Ghost()
with ghost.start():
session = Session(ghost, download_images=False, display=True, user_agent=USER_AGENT)
page,rs = session.open("http://somesite.org/fillme", timeout=120)
assert page.http_status == 200
# this is where i need the input data, to fill the values.
session.evaluate("""
document.querySelector('input[name="DataForm"]').value = "dataInput";
""")
# Do something and close
session.webview.setHtml("")
session.exit()
如何将 inputData 列表中的值传递给脚本内的 querySelector 方法?我一直在尝试一切,到目前为止还没有运气。
使用带有 PyQt4 的 Ghost 0.2.3 运行 python 2.7。提前致谢。