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

边栏推荐
- 鼠标悬停效果四
- STM32 - DS18B20 temperature sampling of first-line protocol
- 安装VCenter6.7【VCSA6.7(vCenter Server Appliance 6.7) 】
- Use ipmitool to configure BMC network and user information of X86 server
- Error accessing URL 404
- 【Qt】添加第三方库的知识补充
- Druid监控统计数据源
- 别再说不会解决 “跨域“ 问题啦
- Druid monitoring statistics source
- A small document of JS method Encyclopedia
猜你喜欢

So easy 将程序部署到服务器

Prototype and prototype chain in JS

倍福TwinCAT3 Ads相关错误详细列表

Densenet network paper learning notes

The best learning method in the world: Feynman learning method

Contrastive learning of Class-agnostic Activation Map for Weakly Supervised Object Localization and

VMware vSphere 6.7 virtualization cloud management 12. Vcsa6.7 update vCenter server license

Gartner research: in China, the adoption of hybrid cloud has become the mainstream trend

【小程序项目开发-- 京东商城】uni-app之首页商品楼层

Network address translation (NAT) technology
随机推荐
Dell server restart Idrac method
Introduction to kubernetes resource objects and common commands (II)
Classic programming problem: finding the number of daffodils
js中的原型和原型链
Chapitre 03 Bar _ Gestion des utilisateurs et des droits
Mnasnet learning notes
【小程序项目开发 -- 京东商城】uni-app 商品分类页面(上)
Cloud native annual technology inventory is released! Ride the wind and waves at the right time
[applet project development -- JD mall] uni app commodity classification page (Part 2)
VMware vSphere 6.7 virtualization cloud management 12. Vcsa6.7 update vCenter server license
Best used trust automation script (shell)
Mouse over effect III
[applet project development -- Jingdong Mall] classified navigation area of uni app
Is it safe to open an account online in a small securities firm? Will my money be unsafe?
Lavaweb [first understanding the solution of subsequent problems]
最好用的信任关系自动化脚本(shell)
[exsi] transfer files between hosts
第03章_用户与权限管理
Restcloud ETL data realizes incremental data synchronization through timestamp
MySQL index --01--- design principle of index