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

边栏推荐
- [QT] add knowledge supplement of third-party database
- VMware vSphere 6.7虚拟化云管理之12、VCSA6.7更新vCenter Server许可
- How to buy Hong Kong shares in China? What platform is safer?
- Huawei operator level router configuration example | configuration optionA mode cross domain LDP VPLS example
- 几行事务代码,让我赔了16万
- 【小程序项目开发--京东商城】uni-app之自定义搜索组件(上)
- Mouse over effect II
- Metadata in NFT
- 大橙子疯博客搬家通知
- 世界上最好的学习法:费曼学习法
猜你喜欢

Redis 教程

Design practice of current limiting components

8 pits of redis distributed lock
![[linear DP] shortest editing distance](/img/2f/9a6f661bf478fdd5d53e5a03d7297d.jpg)
[linear DP] shortest editing distance

Optimal transport Series 1

Communication protocol -- Classification and characteristics Introduction

Sampling Area Lights

Complete training and verification of a neural network based on pytorch

咱就是说 随便整几千个表情包为我所用一下

Chapter 03_ User and authority management
随机推荐
# 使用 KubeKey 搭建 Kubernetes/KubeSphere 环境的'心路(累)历程'
[PR # 5 A] two way running (state pressure DP)
Scale SVG to container without mask / crop
Huawei operator level router configuration example | BGP VPLS configuration example
Is it safe to open an account online in a small securities firm? Will my money be unsafe?
In the industrial Internet, "small" programs have "big" effects
鼠标悬停效果三
PCB defect detection based on OpenCV and image subtraction
PHP batch Excel to word
Mouse over effect 8
[exsi] transfer files between hosts
Mouse over effect II
robots. Txt restrict search engine inclusion
How the network is connected: Chapter 2 (Part 2) packet receiving and sending operations between IP and Ethernet
How to determine the progress bar loaded in the loading interface when opening the game
servlet【初识】
VMware vSphere 6.7 virtualization cloud management 12. Vcsa6.7 update vCenter server license
Golang多图生成gif
别再说不会解决 “跨域“ 问题啦
鼠标悬停效果四