Use Python to crawl the little sister image

First of all on the website link only beautiful girls

The crawling picture is mainly divided into the following steps:

1. Open a website for your favorite little sister

E.g xiaojiejie web

2. Download and install python

Python’s official website

Beginner tutorial – Python environment setup tutorial

3. Start coding

The full python code is as follows

PIP install requests import OS import time import requests # re re import re # change your identity headers = { 'User-Agent': Httpurl = input() response = requests. Get (httpurl,headers = headers) Print (response.request.headers) print(response.text) HTML = response.text view-source:https://www.vmgirls.com/15159.html # link before add the view - the source view page source code dir_name = re. The.findall (' < h1 class = "post - the title h1">(.*?)</h1>',html)[-1] if not os.path.exists(dir_name): OS. The mkdir (dir_name) # regular search urls = re. The.findall (' < a href = "(. *?)" Alt = ". *? "title =". *? "> ', HTML) print (urls) # save pictures for in the url  urls: Name = url.split('/')[-1] Response = requests. Get (" HTTPS :"+ headers = headers) Print (name+ '/'+name,'wb') with open(dir_name+'/'+name,'wb') as f: f.rite (response.content) print(' download done ')Copy the code

Recommended: 020 continuous update, boutique small circle has new content every day, dry goods concentration is very high.

Strong contacts, discussion technology you want here!

Be the first to enter the group and beat your peers! (There is no charge to join the group)

Click here to learn more about Python development.

Group no. : 745895701

Upon application:

Python software installation package, Python tutorial

Free materials, including Basic Python learning, advanced learning, crawler, artificial intelligence, automated operation and maintenance, automated testing, etc

4. Run and download