当前位置:网站首页>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 (*◡‿◡)

边栏推荐
猜你喜欢

Share Creators萌芽人才培养计划来了!
性能测试常见面试题

单片机 MCU 固件打包脚本软件

UE4 rendering pipeline learning notes

Densenet network paper learning notes

The operation efficiency of the park is improved, and the application platform management of applet container technology is accelerated

【机器学习】向量化计算 -- 机器学习路上必经路

世界上最好的学习法:费曼学习法

js中的原型和原型链

最好用的信任关系自动化脚本(shell)
随机推荐
鼠标悬停效果四
性能测试常见面试题
Redis 教程
[machine learning] vectorized computing -- a must on the way of machine learning
Servlet [first introduction]
Ipmitool download address and possible problems during compilation and installation
Mouse over effect VI
[linear DP] longest common subsequence
[QT] add knowledge supplement of third-party database
Detailed explanation of pointer array and array pointer (comprehensive knowledge points)
How to buy Hong Kong shares in China? What platform is safer?
If a parent class defines a parameterless constructor, is it necessary to call super ()?
Lenovo x86 server restart management controller (xclarity controller) or TSM method
# 使用 KubeKey 搭建 Kubernetes/KubeSphere 环境的'心路(累)历程'
[PR # 5 A] two way running (state pressure DP)
Sampling Area Lights
Introduction to the core functions of webrtc -- an article to understand peerconnectionfactoryinterface rtcconfiguration peerconnectioninterface
HTB-Lame
Huawei operator level router configuration example | configuration optionA mode cross domain LDP VPLS example
Huawei operator level router configuration example | BGP VPLS configuration example