2015-03-31 54 views
0

有什麼辦法解析fancyBox的內容? 有一個網頁,其中包含一個class_name,並在fancyBox中包含「href = #free」。它包含一些圖標。 我想知道如何獲得fancyBox數據?python如何獲取fancyBox的數據?

通過使用urlib,我可以訪問網頁的數據以及

找不到關於它的使用解決任何信息

回答

0

webdriver的

import selenium.webdriver as webdriver 
driver = webdriver.Chrome(r"C:\Users\...\chromedriver.exe") 
driver.get("http://...") 
content = driver.find_element_by_xpath('') 
content.click() 
urls = re.findall('https://(?:[a-zA-Z]|[0-9]|[[email protected]&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', driver.page_source) 
for url in urls: 
    if re.match(r'https://.*(jpg|png|gif)$', url): 
     f = open("C:\\..."+ url.split('icons/')[-1],'wb') 
     f.write(urllib.request.urlopen(url).read()) 
     f.close() 
     print(url.split('icons/')[-1])