【发布时间】:2018-04-07 16:15:40
【问题描述】:
我正在尝试完成一个工作项目,在该项目中我会自动获取我们所有打印机的每日点击次数。佳能 iR5070 有一个网络界面,但需要点击几下才能访问,我无法执行链接点击或关注。
我要关注的链接在这个 HTML 中。
<a href="javascript:load_device()" >
<img src="en/media/bm10.gif" border="0", alt="Device Information", title="Device Information">
</a>
如果有帮助,这是有问题的 javascript 函数: 功能:
function load_cdevice() {
chgImg(5);
var cgi_str = "en/pages/d_cbody.htm?";
// for Expire Cache!!
var now_time = new Date();
cgi_str += "Dummy=" + now_time.getTime();
parent.Body.location.href = cgi_str;
}
以下是我尝试失败的内容...(load_cdevice 是我想要的最终目的地,因为这是具有点击计数的页面,但我不确定是否可以从登录页面访问...)
def get_5070_info():
print("Ripping info for Canon Imagerunner 5070")
driver = webdriver.Chrome()
driver.get('http://10.0.0.34')
# driver.implicitly_wait(3)
assert "Remote UI" in driver.title
# 'document.load_cdevice()
# driver.execute_script('load_device()')
# driver.execute_script('load_cdevice()')
# driver.execute_script('javascript:load_device()')
# driver.execute_script('javascript:load_device')
# driver.execute_script('document.load_device()')
# driver.execute_script("window.location = load_device()'")
# driver.execute_script("window.location =avascript:load_device()'")
任何想法或可能会获得此链接的 xpath? href 标签中没有链接文本,只有一个 img 链接。谢谢!
【问题讨论】:
标签: python selenium xpath printing scrape