立即学习:https://edu.youkuaiyun.com/course/play/24756/284653?utm_source=blogtoedu
from selenium import webdriver
driver=webdriver.Chrome(executable_path="C:\Program Files\Google\Chrome\Application\chromedriver.exe")
1.获取html的属性对应的值
driver.get(r"本地html路径")
div=driver.find_element_by_id("mydiv")
print(div.get_property("data-name")) #官方官方属性对应的值
或
print(div.get_attribute("id"))
print(div.get_attribute("data-name"))
#标签的某个属性(包含自定义的属性)的值
2.获取当前页面的截图。这个方法只能在driver上使用
driver.get("http://www5.baidu.com/")
driver.save_screentshot("baidu.png")#保存图片