【发布时间】:2018-06-05 04:36:02
【问题描述】:
我尝试用 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 方法?我一直在尝试一切,但到目前为止没有运气。
运行 python 2.7、Ghost 0.2.3 和 PyQt4。提前致谢。
【问题讨论】:
标签: python web-scraping ghost.py