最近比较忙,晚上换换脑子使用python爬取一点壁纸玩玩,程序比较简单,但是知识点却不少。
    爬取了一百多张,然后我挑选了一些发上来玩玩吧。
    程序大家想研究的话可以往下翻,真的不要太简单了。



图来源于网络,侵删


python爬取一点壁纸_python

 

python爬取一点壁纸_python_02


python爬取一点壁纸_firefox_03

 

python爬取一点壁纸_firefox_04


python爬取一点壁纸_firefox_05


python爬取一点壁纸_firefox_06


python爬取一点壁纸_python_07


python爬取一点壁纸_firefox_08


python爬取一点壁纸_firefox_09


python爬取一点壁纸_firefox_10


python爬取一点壁纸_firefox_11


python爬取一点壁纸_firefox_12


python爬取一点壁纸_firefox_13


python爬取一点壁纸_python_14


python爬取一点壁纸_firefox_15


python爬取一点壁纸_firefox_16


python爬取一点壁纸_firefox_17


python爬取一点壁纸_firefox_18


python爬取一点壁纸_python_19


python爬取一点壁纸_firefox_20


python爬取一点壁纸_firefox_21


python爬取一点壁纸_firefox_22


python爬取一点壁纸_python_23


python爬取一点壁纸_firefox_24


python爬取一点壁纸_python_25


python爬取一点壁纸_python_26


python爬取一点壁纸_python_27


python爬取一点壁纸_firefox_28


python爬取一点壁纸_python_29


python爬取一点壁纸_python_30


python爬取一点壁纸_python_31


python爬取一点壁纸_python_32


python爬取一点壁纸_python_33


python爬取一点壁纸_firefox_34


python爬取一点壁纸_python_35


python爬取一点壁纸_python_36


python爬取一点壁纸_firefox_37


python爬取一点壁纸_python_38


python爬取一点壁纸_python_39


python爬取一点壁纸_python_40


python爬取一点壁纸_firefox_41


python爬取一点壁纸_firefox_42


python爬取一点壁纸_python_43


python爬取一点壁纸_python_44


python爬取一点壁纸_python_45


python爬取一点壁纸_python_46


python爬取一点壁纸_python_47


python爬取一点壁纸_python_48


python爬取一点壁纸_python_49


python爬取一点壁纸_firefox_50


python爬取一点壁纸_python_51


python爬取一点壁纸_python_52


python爬取一点壁纸_python_53


python爬取一点壁纸_firefox_54


python爬取一点壁纸_python_55


python爬取一点壁纸_firefox_56


python爬取一点壁纸_python_57


python爬取一点壁纸_firefox_58


python爬取一点壁纸_python_59


python爬取一点壁纸_python_60


好了好了,先发这么多吧。


程序:

import requests
import re
import uuid


headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0'
}


def getUrls(ALLURL):






response = requests.get(ALLURL,headers=headers).text
# print(response)


result = re.findall('height: auto !important;"><img data-ratio=.*?src="(.*?)"',response,re.S)
# print(result)
return result


def saveImage(url):
response = requests.get(url, headers=headers).content
# print(response)


uuid_str = uuid.uuid4().hex
tmp_file_name = 'tmpfile_%s.jpg' % uuid_str


with open('./saveFolder/'+tmp_file_name,'wb') as f:
f.write(response)






if __name__ == '__main__':
BASE_URL = 'https://mp.weixin.qq.com/s/'
endURL = input("请输入链接的尾部:")
ALLURL = BASE_URL + endURL
# 得到所有图片的url列表
urls = getUrls(ALLURL)


for i in range(len(urls)):
saveImage(urls[i])

(完整链接就不给出了,防止大家玩坏了,需要的可以私聊我)






python爬取一点壁纸_firefox_61