python如何获取fancyBox的数据?

时间:2015-03-31 14:07:00

标签: python fancybox urllib

有没有办法解析fancyBox内容? 有一个网页,其中包含一个带有“href = #free”的class_name到fancyBox。它包括许多图标。 我想知道如何获取fancyBox数据?

通过使用urlib,我也可以访问网页的数据

找不到任何关于它的信息

1 个答案:

答案 0 :(得分: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]|[$-_@.&+]|[!*\(\),]|(?:%[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])