I'm trying to scrape data from a site with multiple pages linked via a NEXT button
The successive page URL has no correspondence with the previous page URL as one might assume
(In that case modifying the path would've solved the problem)
This is what I plan to do -
1.Start with an initial URL
2.Extract information
3.Click NEXT
Repeat 2 and 3 n times
Specifically, I wanted to know how to get the new page URL on clicking
This is what I've come up with so far
def startWebDriver():
global driver
options = Options()
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(executable_path = '/path/to/driver/chromedriver_linux64/chromedriver',options=options)
#URL of the initial page
driver.get('https://openi.nlm.nih.gov/detailedresult.php?img=CXR1_1_IM-0001-3001&query=&coll=cxr&req=4&npos=1')
time.sleep(4)
#XPATH of the "NEXT" button
element = driver.find_element_by_xpath('//*[@id="imageClassM"]/div/a[2]/img').click()
Any help would be appreciated