python 如何获取fancyBox的数据?
python how to get data of the fancyBox?
有没有办法解析fancyBox的内容?
有一个网页包含 class_name 和 "href = #free" 到 fancyBox。它包括许多图标。
请问如何获取fancyBox数据?
通过urlib,我也可以访问网页的数据
找不到任何相关信息
使用 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])
有没有办法解析fancyBox的内容? 有一个网页包含 class_name 和 "href = #free" 到 fancyBox。它包括许多图标。 请问如何获取fancyBox数据?
通过urlib,我也可以访问网页的数据
找不到任何相关信息
使用 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])