My code goes into a webpage, and can click on each row of the page.
I want to ultimately, open each link of each row as a new page, so I can save the URL of each page.
I cannot get the URL without Seleniums .click() (i believe), so I resorted to .click, and then get the currentURL.
This code works only for the first row, as the webpage exits the original URL.
Is there a more efficient way to print the URLS of each row?
from selenium import webdriver
import time
sam=[]
import pandas as pd
driver = webdriver.Chrome()
for x in range (1,8):
driver.get(f'https://www.abstractsonline.com/pp8/#!/9325/presentations/endometrial/{x}')
time.sleep(3)
page_source = driver.page_source
eachrow=driver.find_elements_by_xpath('//*[@id="results"]/li')
for item in eachrow:
oth = item.find_element_by_xpath(".//h1[@class='name']")
oth.click()
print(driver.current_url)
<h1>tag? If you have an<a>tag, you can fetch thehrefattribute from it without clicking on it.