我有以下代码:
from selenium import selenium
selenium = selenium("localhost", 4444, "*chrome", "http://some_site.com/")
selenium.start()
sel = selenium
sel.open("/")
sel.type("ctl00_ContentPlaceHolder1_SuburbTownTextBox", "Adelaide,SA,5000")
sel.click("ctl00_ContentPlaceHolder1_SearchImageButton")
#text = sel.get_body_text()
text = sel.get_html_source()
print(text)
点击执行javascript文件,然后在同一页面上生成结果。显然print(text)
只会打印orignal html源代码。我如何获得javascript的结果?
答案 0 :(得分:4)
尝试使用id = your-id:
获取html元素的内容sel.get_eval("this.browserbot.getCurrentWindow().document.getElementById('your-id').innerHTML"