Click here to Skip to main content
15,887,992 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
There is a website which shows links on a map (map layer currently can't be shown but links can be shown as points). To view this website, this must be followed: (Pictures 1-2-3 also shows the way)

Firstly, click this website 'http://svtbilgi.dsi.gov.tr/Sorgu.aspx', pic 1 https://i.stack.imgur.com/NVOUT.jpg

Secondly, choose '15. Kizilirmak Havzasi' from 'Havza' tab, https://i.stack.imgur.com/w0lVY.jpg Picture 2

Finally, click 'sorgula' bottom. https://i.stack.imgur.com/3VtJD.jpg Picture 3

After the final stage, you should view the website ('http://svtbilgi.dsi.gov.tr/HaritaNew.aspx') where the points can be shown on a map. https://i.stack.imgur.com/2T0uV.jpg Picture 4

Normally, I can use selenium to download web pages or can grab all links using different libraries. However, these methods can't obtain the links because they are embedded almost in a secret way.

I would like to download all the links that these points have.

What I have tried:

Python
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait


driver = webdriver.Firefox(executable_path=r'D:\geckodriver.exe')
driver.get("http://svtbilgi.dsi.gov.tr/Sorgu.aspx")
driver.find_element_by_id("ctl00_hld1_cbHavza").click()
Select(driver.find_element_by_id("ctl00_hld1_cbHavza")).select_by_visible_text("15. Kizilirmak Havzasi")
driver.find_element_by_id("ctl00_hld1_cbHavza").click()
driver.find_element_by_id("ctl00_hld1_btnListele").click()
parent_handle = driver.current_window_handle
all_urls = []
all_images = driver.find_elements_by_xpath("//div[contains(@id,'OL_Icon')]/img")
for image in all_images :
     image.click()
     for handle in driver.window_handles :
          if handle != parent_handle:
              driver.switch_to_window(handle)
              WebDriverWait(driver, 5).until(lambda d: d.execute_script('return document.readyState') == 'complete')
              all_urls.append(driver.current_url)
              driver.close()
              driver.switchTo.window(parent_handle)
Posted
Updated 26-Jul-18 19:10pm
v2
Comments
Richard MacCutchan 27-Jul-18 4:44am    
Links are hidden in this way to prevent people from stealing them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900