首页 > 编程语言 >python实现抓取表情网站图片

python实现抓取表情网站图片

时间:2024-01-17 10:05:41浏览次数:39  
标签:python 抓取 headers 537.36 url images import os 表情

1:效果图

python实现抓取表情网站图片_Chrome

2:代码

import os
import requests
from bs4 import BeautifulSoup
 
if not os.path.exists('./images/'):
    os.mkdir('./images/')
 
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36 SE 2.X MetaSr 1.0'
}
 
url = 'http://wx4.sinaimg.cn/large/ceeb653ely8gw2o2b5f61j20jz0j5dgr'
 
response = requests.get(url, headers=headers)
 
name = '图片.jpg'
with open(f'./images/{name}', 'wb')as f:
    f.write(response.content)

标签:python,抓取,headers,537.36,url,images,import,os,表情
From: https://blog.51cto.com/yangshaoping/9284990

相关文章