Python obtains the src attribute after locating the picture through selenium

created at 08-01-2021 views: 2

Import selenium directly

from selenium import webdriver

After opening the webpage through the following two ways
To identify the ID to obtain the desired object

driver.find_element_by_xpath("//*[@ id='imgObj']")

After obtaining the object, use the get_attribute method to get other attributes of the object

driver.find_element_by_xpath("//*[@ id='imgObj']").get_attribute("src")

This method can also be used to get pictures in batches
It is definitely more convenient and convenient to compare regular expressions to take pictures and then recognize src.

The selenium documentation only talks about how to locate, but it doesn’t explain how to take other elements after positioning.

created at:08-01-2021
edited at: 08-01-2021: