![]() |
Download all secret links from a map design website - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Download all secret links from a map design website (/thread-11765.html) |
Download all secret links from a map design website - fyec - Jul-24-2018 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-4 also show the way) Firstly, click this website 'http://svtbilgi.dsi.gov.tr/Sorgu.aspx', Picture 1 Secondly, choose '15. Kizilirmak Havzasi' from 'Havza' tab, Picture 2 Finally, click 'sorgula' bottom. 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. Picture 4 Normally, I can use selenium to download webpages 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 links that these points have. How can I get them? 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_handleThis script doesn't continue after 'parent_handle = driver.current_window_handle' line. |