Python collects beautiful girl

Time:2020-12-5
import requests;
import re;
import os;
#1. Request web page
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. Parsing web pages

urls = re.findall('<img .*?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. Save the picture
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)

Python collects beautiful girl

The background management system of high appearance value is free to use. It can be directly installed on the pagoda panel

Welcome to my official account: the wonderful world of Zi Feng, exclusive learning resources and daily dry cargo push.
If you are interested in my other topics, go to my personal blog: www.wangmingchang.com 。