当前位置:网站首页>Let's just say I can use thousands of expression packs
Let's just say I can use thousands of expression packs
2022-07-01 03:05:00 【Panda aiqia rice】
Preface
In today's era when everyone has a mobile phone , Many people chat online , however , How to quickly alleviate embarrassment and enter a happy and pleasant chat ~
A friend I just met threw a few expression packs out and pulled into the relationship every minute , The girlfriend was sulky, and the whole two expressions made her happy , It can also resolve embarrassment , There's no time to type the whole two expression packs , Politeness without embarrassment . I don't know when to go back , It's even more like losing an expression package and solving it in minutes
Now young people chat , I'm embarrassed to say I'm a young man without an expression , Expression pack has become an indispensable part of people's chat .
preparation (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)
Preparation is important , First know what we're going to do , What to do with , How do you do it? , Go step by step , Slowly but surely .
Development environment configuration
- Python 3.6
- Pycharm
If you have a partner who has not installed it, you can get it from the home page on the left or send me a private letter to get the installation tutorial ~
Module installation configuration
- requests
- parsel
- re
Third-party module , We need to install : (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)
win + R Input cmd Enter the installation command pip install Module name If there is a burst of red Probably because Network connection timeout Switch domestic image source
stay pycharm Click on the Terminal( terminal ) Enter the installation command
How to configure pycharm Inside python Interpreter ?
choice file( file ) >>> setting( Set up ) >>> Project( project ) >>> python interpreter(python Interpreter )
Click on the gear , choice add
add to python The installation path
pycharm How to install plug-ins ?
- choice file( file ) >>> setting( Set up ) >>> Plugins( plug-in unit )
- Click on Marketplace Enter the name of the plug-in you want to install such as : Translation plug-ins Input translation / Chinese plug-in Input Chinese
- Select the corresponding plug-in and click install( install ) that will do
- After successful installation Yes, it will pop up restart pycharm The option to Click ok , Restart to take effect
Code
The goal is :fabiaoqing
Please fill in the front and back of the address by yourself , Including the following code , There should be no such thing as that .
The import module
import requests
import parsel
python Learning exchange group :660193417 ###
import re
import time
Request URL
url = f'fabiaoqing/biaoqing/lists/page/{page}.html'
Request header
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'
}
Return to the web page source code (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)
response = requests.get(url=url, headers=headers)
get data
# First extraction Extract all of div Label content
divs = selector.css('#container div.tagbqppdiv') # css Extract the content according to the label
# Extract his picture from the tag content url Address
img_url = div.css('img::attr(data-original)').get()
# Extract the title
title = div.css('img::attr(title)').get()
# Get the suffix of the picture
name = img_url.split('.')[-1]
Save the data
new_title = change_title(title)
Send a request to the emoticon package picture Get its binary data
img_content = requests.get(url=img_url, headers=headers).content
Save the data
def save(title, img_url, name):
img_content = get_response(img_url).content
try:
with open('img\\' + title + '.' + name, mode='wb') as f:
# Write picture binary data
f.write(img_content)
print(' Saving :', title)
except:
pass
# Replace special characters in the title python Learning exchange group :660193417 ###
# Because the file name is unknown and there are special characters , So we need to replace special characters with regular expressions .
def change_title(title):
new_title = re.sub(mode, "_", title)
return new_title
Recording time
time_2 = time.time()
use_time = int(time_2) - int(time_1)
print(f' The total time is :{use_time} second ')
Multithreading (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)
import requests
import parsel
import re
import time
import concurrent.futures
def change_title(title):
new_title = re.sub(mode, "_", title)
return new_title
def get_response(html_url):
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'
}
repsonse = requests.get(url=html_url, headers=headers)
return repsonse
def save(title, img_url, name):
img_content = get_response(img_url).content
try:
with open('img\\' + title + '.' + name, mode='wb') as f:
f.write(img_content)
print(' Saving :', title)
except:
pass
def main(html_url):
html_data = get_response(html_url).text
selector = parsel.Selector(html_data)
divs = selector.css('#container div.tagbqppdiv')
for div in divs:
img_url = div.css('img::attr(data-original)').get()
title = div.css('img::attr(title)').get()
name = img_url.split('.')[-1]
new_title = change_title(title)
save(new_title, img_url, name)
if __name__ == '__main__':
time_1 = time.time()
exe = concurrent.futures.ThreadPoolExecutor(max_workers=10)
for page in range(1, 201):
url = f'fabiaoqing/biaoqing/lists/page/{page}.html'
exe.submit(main, url)
exe.shutdown()
time_2 = time.time()
use_time = int(time_2) - int(time_1)
print(f' The total time is :{use_time} second ')
I'm a panda , See you in the next article (*◡‿◡)
边栏推荐
- Poj-3486-computers[dynamic planning]
- Mouse over effect 7
- 咱就是说 随便整几千个表情包为我所用一下
- How to open a stock account? Also, is it safe to open an account online?
- 调试定位导航遇到的问题总结
- HTB-Lame
- IEDA 右键源码文件菜单简介
- 访问url 404 的错误
- 8 pits of redis distributed lock
- POI exports excel and displays hierarchically according to parent-child nodes
猜你喜欢
Communication protocol -- Classification and characteristics Introduction
Lavaweb [first understanding the solution of subsequent problems]
世界上最好的学习法:费曼学习法
Detailed explanation of pointer array and array pointer (comprehensive knowledge points)
[small program project development -- Jingdong Mall] the home page commodity floor of uni app
Restcloud ETL practice data row column conversion
UE4 rendering pipeline learning notes
Here comes the share creators budding talent training program!
Sampling Area Lights
Example of Huawei operator level router configuration | example of configuring optionc mode cross domain LDP VPLS
随机推荐
[exsi] transfer files between hosts
单片机 MCU 固件打包脚本软件
[applet project development -- JD mall] uni app commodity classification page (first)
Catch 222222
Voici le programme de formation des talents de SHARE Creators!
STM32——一线协议之DS18B20温度采样
Why are strings immutable in many programming languages? [repeated] - why are strings immutable in many programming languages? [duplicate]
股票开户安全吗?上海股票开户步骤。
Introduction to kubernetes resource objects and common commands (II)
Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip
LeetCode_ Stack_ Difficulties_ 227. basic calculator (excluding multiplication and division)
PTA 1017
An article explaining the publisher subscriber model and the observer model
Is it safe to open a stock account? Shanghai stock account opening procedures.
Mouse over effect II
How to verify whether the contents of two files are the same
Use ipmitool to configure BMC network and user information of X86 server
Detailed explanation of pointer array and array pointer (comprehensive knowledge points)
Example of Huawei operator level router configuration | example of configuring optionc mode cross domain LDP VPLS
别再说不会解决 “跨域“ 问题啦