当我比较这两个标记时,我发现区别在于类标记。
所以如果你能读的话你就完了
如果你喜欢,可以用硒来做
步骤1:查找XPath
-获取按钮的XPath:在Chrome中打开页面,点击它并选择Inspect element
-它将打开html文件,右键单击突出显示的行并选择copy Xpath
-在记事本中复制XPath
既然已经有了XPath,就可以通过Python脚本选择按钮并查询属性
这是一个原型from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get(“http://www.youradress.org”)#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()
希望对你有帮助,如果你有问题请告诉我
我把这些链接用于文档