王者荣耀高清皮肤下载
本帖最后由 zyjsuper 于 2020-8-16 22:47 编辑初学ChromeDriver +Selenium,分享下学习的小成果给坛友们,很多地方还需要优化,没有详细的做注释,大家凑合着看吧。
chromedriver下载地址:
墙外:https://sites.google.com/a/chromium.org/chromedriver/downloads
墙内:http://npm.taobao.org/mirrors/chromedriver/
https://chromedriver.storage.googleapis.com/index.html
参考链接:
https://blog.csdn.net/KaryKwok/article/details/80952084
https://blog.csdn.net/weixin_36279318/article/details/79475388
下载不易,把下载好的分享给大家:https://ws28.cn/f/39s6bzsqeug 过期时间: 1 天, 23:51:48
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Author: zyjsuper
@License : (C) Copyright 2013-2020
@Contact : [email protected]
@File : chromeSpider.py
@Time : 2020/8/16 19:46
@Desc :
'''
import time,os
from selenium import webdriver
import requests
browser = webdriver.Chrome()
headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
username = os.getenv("USERNAME")
savepath = "C:\\Users\\"+ username + "\\Desktop\\Photos\\"
try:os.mkdir(savepath)
except:pass
browser.get("https://pvp.qq.com/web201605/wallpaper.shtml")
time.sleep(2)
page = 1
while True:
i = 1
urls = browser.find_elements_by_xpath("//div[@class='p_hd']//li[@class='sProdImgDown sProdImgL7']/a")
for url in urls:
pic_name =browser.find_element_by_xpath("//div[@class='p_hd']//div[" + str(i) + "]/h4").text
real_url = url.get_attribute("href")
path = savepath + str(page)
try:os.mkdir(path)
except:pass
response = requests.get(real_url,headers=headers)
with open(path + "\\" + pic_name + ".jpg",'wb') as file:
file.write(response.content)
print(path + "\\" + pic_name + ".jpg has been saved.")
i += 1
if i ==21:
break
browser.find_element_by_class_name("downpage").click()
page += 1
页:
[1]