失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > python打开网页后点击网页按钮_python单击网页上的按钮

python打开网页后点击网页按钮_python单击网页上的按钮

时间:2024-07-05 05:11:11

相关推荐

python打开网页后点击网页按钮_python单击网页上的按钮

当我比较这两个标记时,我发现区别在于类标记。

所以如果你能读的话你就完了

如果你喜欢,可以用硒来做

步骤1:查找XPath

-获取按钮的XPath:在Chrome中打开页面,点击它并选择Inspect element

-它将打开html文件,右键单击突出显示的行并选择copy Xpath

-在记事本中复制XPath

既然已经有了XPath,就可以通过Python脚本选择按钮并查询属性

这是一个原型from selenium import webdriver

from mon.keys import Keys

driver = webdriver.Firefox()

driver.get("")#put here the adress of your page

elem = driver.find_elements_by_xpath("//*[@type='submit']")#put here the content you have put in Notepad, ie the XPath

print(elem.get_attribute("class"))

driver.close()

希望对你有帮助,如果你有问题请告诉我

我把这些链接用于文档

如果觉得《python打开网页后点击网页按钮_python单击网页上的按钮》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。