当前位置:网站首页>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 ')边栏推荐
- Chrome extension development Chinese tutorial-1
- How to reduce snapshots
- JS chain call
- Authentication can be as simple as this - use the API gateway to protect your API security
- 【TypeScript】在实战中的一些总结
- What hard disk does the ECS use? What are the functions of the ECS
- Is it safe to open an account with flush?
- How to solve the problem that the ID is not displayed when easycvr edits the national standard channel?
- How many of the five app automated test AIDS have you used?
- Elegant asynchronous programming version answer async and await parsing
猜你喜欢

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

Steps for formulating the project PMO strategic plan
![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
Application of JDBC in performance test

Uncover the secrets of Huawei cloud enterprise redis issue 16: acid'true' transactions beyond open source redis

I am 30 years old, no longer young, and have nothing

New SQL syntax quick manual!

How PMO uses two dimensions for performance appraisal

Lightweight, dynamic and smooth listening, hero earphone hands-on experience, can really create
随机推荐
What is a database index? Xinhua dictionary to help you
How to gradually improve PMO's own ability and management level
I am 30 years old, no longer young, and have nothing
Overview of digital circuits
How to convert []byte to io. in go Reader?
What is the process of opening a mobile card account? Is online account opening safe?
Global and Chinese market of fly killers 2022-2028: Research Report on technology, participants, trends, market size and share
Cobalt Strike Spawn & Tunnel
Drawing STM32 minimum system schematic diagram with AD
Memory patch amsi bypass
Stm32 w5500 implements TCP, DHCP and web server
Cool 3D sphere text cloud effect!
A detailed discussion on the use guide of network Swiss Army knife nmap
Encryption and decryption analysis of returned data of an e-commerce app (IV)
SAP retail wrmo replenishment monitoring
How to evaluate performance optimization? Covering too much knowledge?
100 lines of code, using pyGame to make a snake game!
What are the processing methods for PPT pictures
Real time crawler launches a number of special new products
[Debian] Debian usage notes