python 採集惟美girl

import requests;
import re;
import os;
# 1.請求網頁
header = {
    "user-agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'
}
response = requests.get('https://www.vmgirls.com/2957.html',headers=header)
# print(response.text)
html =  response.text

# 2.解析網頁

urls = re.findall('<img alt="(.*?)" .*?data-pagespeed-lsc-url="(.*?)".*?>',html)
dir_name = re.findall('<h1 class="post-title h3">(.*?)</h1>',html);
dir_name = dir_name[0]
if not os.path.exists(dir_name):
    os.mkdir(dir_name)
# print(urls)
# print(dir_name)

# 3.保存圖片
for url in urls:
    file_name = url[1].split('/')[-1]
    # print(file_name)
    # print(url[1])
    response = requests.get(url[1],headers=header)
    with open(dir_name+'/'+file_name,'wb') as f:
        f.write(response.content)

image-20200728000315699

高顏值後臺管理系統無償使用 ### 子楓後臺管理系統 ###,可在寶塔面板直接安裝html

歡迎關注個人公衆號:子楓的奇妙世界,得到獨家整理的學習資源和平常乾貨推送。
若是您對個人其餘專題內容感興趣,直達個人我的博客:www.wangmingchang.compost

相關文章
相關標籤/搜索