当前位置:网站首页>High quality "climbing hand" of course, you have to climb a "high quality" wallpaper
High quality "climbing hand" of course, you have to climb a "high quality" wallpaper
2022-06-23 21:29:00 【Charlie is not a dog】
One 、 Write it at the front
Every day my wallpaper is Windows Own sky blue , It's really boring , Interesting , boring ~
So! , as everyone knows , I am a blogger who likes high quality , Of course, the whole hand of high-quality wallpaper , I don't have other meaning? .
Okay , No more beeps , Start today's high-quality journey ~
Two 、 preparation
All these arrangements
python 3.6 pycharm requests parsel
3、 ... and 、 Reptile process
======================================================================
1) About data source search :
1、 Identify target requirements : Climb to HD Wallpaper pictures ( The other shore )
Through developer tools (F12 Or right click to check ) Looking for pictures url Address source ;
request Detail page of wallpaper Get its web page source code You can get pictures url Address ( a sheet );
request The list page can get The detail page of each wallpaper url as well as title ;
2) Code implementation :
1、 Send a request
List page of wallpaper url: http://www.netbian.com/1920x1080/index.htm
2、 get data
Web source code / response.text Web page text data
3、 Parsing data
css xpath bs4 re
Wallpaper details page url:/desk/23397.htm 2. Wallpaper title
4、 Save the data
Saving pictures is binary data
Audience grandpa : That's it. That's it ? What about code? ? The code doesn't give you a few meanings ?
Don't panic. , Here it is... Here it is
Four 、 Code display
I don't think so Once disassembled , Add the third step , Believe that smart you can understand , I really can't. finally, I'll play a video to explain .
import requests # Request module Third-party module pip install requests
import parsel # Data analysis module Third-party module pip install parsel
import time # Time module Built-in module
time_1 = time.time()
# What module do you want First, you need to know what the module is for
for page in range(2, 12):
print(f'==================== Climbing to the top {page} The data content of the page ====================')
url = f'http://www.netbian.com/1920x1080/index_{page}.htm'
# Request header : hold python The code disguises itself as a browser sending a request to the server
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
}
response = requests.get(url=url, headers=headers)
# What to do if there is a mess ? Transcoding required
# html_data = response.content.decode('gbk')
response.encoding = response.apparent_encoding # Automatic transcoding
# Get source code / Get web page text data response.text
# print(response.text)
# Parsing data
selector = parsel.Selector(response.text)
# CSS Selectors Is to extract data according to the content of web page tags
# First extraction Extract all of li Label content
lis = selector.css('.list li')
for li in lis:
# http://www.netbian.com/desk/23397.htm
title = li.css('b::text').get()
if title:
href = 'http://www.netbian.com' + li.css('a::attr(href)').get()
response_1 = requests.get(url=href, headers=headers)
selector_1 = parsel.Selector(response_1.text)
img_url = selector_1.css('.pic img::attr(src)').get()
img_content = requests.get(url=img_url, headers=headers).content
with open('img\\' + title + '.jpg', mode='wb') as f:
f.write(img_content)
print(' Saving : ', title)
time_2 = time.time()
use_time = int(time_2) - int(time_1)
print(f' Total time taken {use_time} second ')边栏推荐
- What are the advantages of attaching a virtual machine to a hard disk cloud server
- Bypass memory integrity check
- What about the cloud disk service status error? How to format the cloud disk service?
- 数字电路概述
- Talk about leap seconds
- 【TypeScript】在实战中的一些总结
- How does the video platform deployment give corresponding user permissions to the software package files?
- Spingboot reads the parameter values in the YML configuration file
- Summary of multiple methods for obtaining the last element of JS array
- [5 minutes to play lighthouse] quickly use Chang'an chain
猜你喜欢

What are the main dimensions of PMO performance appraisal?

Facing the problem of lock waiting, how to realize the second level positioning and analysis of data warehouse

Beitong G3 game console unpacking experience. It turns out that mobile game experts have achieved this

I am 30 years old, no longer young, and have nothing
![Harmonyos application development -- mynotepad[memo][api v6] based on textfield and image pseudo rich text](/img/b1/71cc36c45102bdb9c06e099eb42267.jpg)
Harmonyos application development -- mynotepad[memo][api v6] based on textfield and image pseudo rich text

How to gradually improve PMO's own ability and management level

Lightweight, dynamic and smooth listening, hero earphone hands-on experience, can really create

Four aspects of PMO Department value assessment
Application of JDBC in performance test

How PMO uses two dimensions for performance appraisal
随机推荐
Full instructions for databinding
Talk about leap seconds
Share a super Mary source code
Stm32 w5500 implements TCP, DHCP and web server
Customize view to imitate today's headlines and like animation!
How to view the role of PMO in agile organizations?
Spend small money to do big things: cloud function + cloud development leverages the practice of e-commerce promoting flexible architecture in CCTV evening party
What about the cloud disk service status error? How to format the cloud disk service?
Game security - call analysis - write code
How do I clean the ECS hard disk? Why do I clean the hard disk regularly?
How to gradually improve PMO's own ability and management level
Gin security -2: fast implementation of server-side JWT verification
How to handle the prompt that DNS is incorrect when adding resolution to Tencent cloud?
DM sub database and sub table DDL "optimistic coordination" mode introduction - tidb tool sharing
Drawing STM32 minimum system schematic diagram with AD
What are the advantages of attaching a virtual machine to a hard disk cloud server
Global and Chinese market of American football catch gloves 2022-2028: Research Report on technology, participants, trends, market size and share
How to Net project migration to NET Core
Salesforce heroku (IV) application in salesforce (connectedapp)
SAP retail wrmo replenishment monitoring