I am trying to retrieve text from the website (https://www.doc.govt.nz/parks-and-recreation/places-to-go/otago/places/dunedin-area/?tab-id=50578). I am trying to extract information present on the website. Here is my code that is retrieving the text:
driver = webdriver.Chrome(driverLocation)
driver.get('https://www.doc.govt.nz/parks-and-recreation/places-to-go/otago/places/dunedin-area/?tab-id=50578')
driver.implicitly_wait(20)
for element in driver.find_elements_by_xpath('//div[@class="profile-detail"]'):
desc = element.find_element_by_xpath('//div[@class="profile-detail-body"]').text
info = element.find_element_by_xpath('//div[@class="profile-info"]').text
print(desc)
print(info)
The problem is that it always repeats the first entry of the information present on the page (i.e. Allans Beach Track information). When I tried to retrieve the information using two separate loops, it works fine. Could you please guide me where am I making the mistake?