I need to find all href
inside class="mozaique"
My code:
gfd = driver.find_elements_by_xpath('/html[1]/body[1]/div[1]/div[4]/div[2]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]')
I need to find all href
inside class="mozaique"
My code:
gfd = driver.find_elements_by_xpath('/html[1]/body[1]/div[1]/div[4]/div[2]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]')
Below xpath should help you fetch all the links under tag:
<div> class='mozaique'</div>
Xpath:
//div[@class='mozaique']//a[contains(@href,'')]
You can print the href's using the below code snippet:
links = driver.find_elements_by_xpath('//div[@class='mozaique']//a[contains(@href,'')]')
for link in links:
print(link.get_attribute("href"))
First, get your parent element:
parent = driver.find_element_by_class_name("mozaique")
Then get a list of all 'a' tags within your parent element.
a = parent.find_elements_by_tag_name("a")
Then run a loop to print the hrefs
for x in a:
print(x.get_attribute("href"))