# 爬取图片
import requests # 负责爬取
import base64
import csv
root = 'https://aip.baidubce.com/oauth/2.0/token'
tokendata = {
'grant_type':'client_credentials',
'client_id':'xR5XsQ2hAoF2mN8SgY9bruBN',
'client_secret':'YbpQ0M33KNQ9R5t4MyOxgfK0wG5OO3ql',
}
response = requests.post(root,data=tokendata)
access_token = response.json()['access_token']
print(access_token)
# -----------------------------------------------------
# 对图片进行颜值获取
url = f'https://aip.baidubce.com/rest/2.0/face/v3/detect?access_token={access_token}'
headers = {
'Content-Type':'application/json'
}
data = {
'image':'',
'image_type':'BASE64',
'face_field':'beauty'
}
ll = []
with open('../files/wzlw.csv',encoding='utf-8') as fread:
reader = csv.DictReader(fread)
for r in reader:
try:
with open(f'../images/{r["username"]}.png','rb') as f:
data['image'] = base64.b64encode(f.read())
response = requests.post(url,headers=headers,data=data)
beauty = response.json()['result']['face_list'][0]['beauty']
ll.append([r["username"],beauty])
print(r["username"],beauty)
except:
pass
ll2 = sorted(ll,key=lambda x:x[1]) # 以颜值进行排序
with open('../files/yz.csv','w',encoding='utf-8',newline='') as f:
writer = csv.writer(f)
writer.writerow(["username","beauty"])
writer.writerows(ll2)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Python爬虫开源项目代码0 81个Python爬虫源代码+九款开源爬虫工具,81个Python爬虫源代码,内容包含新闻、视频、中介、招聘、图片资源等网站的爬虫资源81个Python爬虫源代码+九款开源爬虫工具,81个Python爬虫源代码,内容包含新闻、视频、中介、招聘、图片资源等网站的爬虫资源 81个Python爬虫源代码+九款开源爬虫工具,81个Python爬虫源代码,内容包含新闻、视频、中介、招聘、图片资源等网站的爬虫资源 81个Python爬虫源代码+九款开源爬虫工具,81个Python爬虫源代码,内容包含新闻、视频、中介、招聘、图片资源等网站的爬虫资源 81个Python爬虫源代码+九款开源爬虫工具,81个Python爬虫源代码,内容包含新闻、视频、中介、招聘、图片资源等网站的爬虫资源 81个Python爬虫源代码+九款开源爬虫工具,81个Python爬虫源代码,内容包含新闻、视频、中介、招聘、图片资源等网站的爬虫资源 81个Python爬虫源代码+九款开源爬虫工具,81个Python爬虫源代码,内容包含新闻、视频、中介、招聘、图片资源等网站的爬虫资源
资源推荐
资源详情
资源评论
收起资源包目录
照片颜值排行源代码.zip (3个子文件)
亦云 2019-8-18 颜值排行
roleInfo.py 754B
yzph.py 1KB
InfoSpider.py 889B
共 3 条
- 1
资源评论
普罗旺斯จุ๊บ
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功