有没有办法解析fancyBox内容? 有一个网页,其中包含一个带有“href = #free”的class_name到fancyBox。它包括许多图标。 我想知道如何获取fancyBox数据?
通过使用urlib,我也可以访问网页的数据
找不到任何关于它的信息
答案 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])