一、进入到B站直播,陪伴学习分区 (*^_^*)

地址为:https://live.bilibili.com/p/eden/area-tags?visit_id=5d9mhghosak0&areaId=372&parentAreaId=11

JSON文件:https://api.live.bilibili.com/xlive/web-interface/v1/second/getList?platform=web&parent_area_id=1&page=2

爬取封面图片

# 网络请求
import requests
import threading
headers = {# 伪装成浏览器发送请求'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
}def get_beauty(url):"""爬取封面然后进行保存"""res = requests.get(url, headers=headers)json_data =res.json()# print(json_data)zb_list = json_data['data']['list']for zb in zb_list:name = zb.get('uname')img_url = zb.get('user_cover')imgPath = 'picture/%s.jpg' %name# 保存图片# 向图片的URL地址发送请求res_img = requests.get(img_url, headers=headers)# 如果是图片,返回二进制# 拿到返回的结果img_data = res_img.contentwith open(imgPath, 'wb') as fp:fp.write(img_data)fp.flush()# 数据解析
# 数据存储
# 有效的URL:https://api.live.bilibili.com/xlive/web-interface/v1/second/getList?platform=web&parent_area_id=1&page=2
if __name__ == '__main__':t_list = []url = 'https://api.live.bilibili.com/xlive/web-interface/v1/second/getList?platform=web&parent_area_id=1&page=2'# 创建线程 多个线程一起爬取t = threading.Thread(target=get_beauty, args=(url, ))t.start()t_list.append(t)for tl in t_list:tl.join()

二、对小姐姐们的颜值进行打分

1、使用百度AI

2、百度颜值打分

import requests
import json
import base64
import time
import pandas as pd
import os
# 查看百度ai提供的文档
class BaiduPicDetect:def __init__(self):self.AK = 'LFKCe35BlHmWSfcmGUFXxRDS'self.SK = 'dIHYqRRTVFR7QI7UjZL86CIMs71GV739'self.headers = {'Content-type': 'application/json;charset=UTF-8'}# 获取tokendef get_access_token(self):host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id='+self.AK+ '&client_secret='+self.SKresponse = requests.get(host, headers=self.headers)# 返回JSONjson_result = json.loads(response.text)# JSON反序列化return json_result['access_token']# 把图片转成base64def image_to_base64(self, path):with open(path, 'rb')as f:base_data = base64.b64encode(f.read())return base_data# 把图片提交def detect_face(self, img_scr):img_base64 = self.image_to_base64(img_scr)request_url = "https://aip.baidubce.com/rest/2.0/face/v3/detect"params = {# 转成base64后的图片"image": img_base64,# 类型"image_type": "BASE64",# 需要返回的字段"face_field": "gender, age, beauty","facetype": "LIVE"}access_token = self.get_access_token()request_url = request_url + "?access_token=" + access_tokenresponse = requests.post(url=request_url, data=params, headers=self.headers)if response:json_result = response.json()age = 0beauty = 0gender = ''if json_result['error_msg'] == 'Success':try:age = json_result['result']['face_list'][0]['age']beauty = json_result['result']['face_list'][0]['beauty']gender = json_result['result']['face_list'][0]['gender']['type']except Exception as e:print("错误")return age, beauty, genderdef check_beauty(path):files = os.listdir(path)files = [path + "/" + file for file in files]b = BaiduPicDetect()# 存放每个图片的检测结果result = []for file in files:print(file)name = file.split('/')[-1][:5]# 获取图片的名称myresult = b.detect_face(file)if myresult != None:age, beauty, gender = myresultresult.append([name, age, beauty, gender])time.sleep(1)df = pd.DataFrame(result, columns=['name', 'age', 'beauty', 'gender'])return df
#
if __name__ == '__main__':path = 'picture'result = check_beauty(path)result.to_csv('./beauty.csv', index=False)print('完成')

但这里存储的csv文件中没有打出分值,也是很迷惑 。希望各位大神,帮帮孩子看是什么错误/(ㄒoㄒ)/~~

爬取B站直播小姐姐封面相关推荐

  1. 爬取B站直播流 - http+flv的相关研究

    参考链接 HTTP-FLV直播初探 HTTP-FLV的两种方式 Json将&符号转成了 \u0026 python requests提示警告InsecureRequestWarning 爬取B ...

  2. Python爬虫:运用多线程、IP代理模块爬取百度图片上小姐姐的图片

    Python爬虫:运用多线程.IP代理模块爬取百度图片上小姐姐的图片 1.爬取输入类型的图片数量(用于给用户提示) 使用过百度图片的读者会发现,在搜索栏上输入关键词之后,会显示出搜索的结果,小编想大多 ...

  3. Python爬取不羞涩网小姐姐图片——BeautifulSoup应用

    引言 今年提倡原地过年,相信很多朋友都没有回家过年,像我就被迫留在深圳过年了,无聊之余只能去看看电影爬爬山.今天给大家带来一个打发无聊时光的案例,用Python爬取不羞涩网小姐姐图片,并保存到本地,老 ...

  4. python爬取b站直播弹幕代码

    以下是使用Python爬取B站直播弹幕的代码示例: import requests import json import timedef get_real_url(room_id):# 获取直播间的真 ...

  5. python实战| 爬取虎牙高质量小姐姐私房照!

    今天给大家介绍python如何爬取虎牙小姐姐并制作心形照片墙, 有兴趣的小伙伴们一起来看看吧! 点击进去,这颜值..... i了i了 需求分析 我们的目标有5个,分别是小姐姐的 房间名称.封面照片.昵 ...

  6. BeautifulSoup爬取唯美girls小姐姐图片

    0. 美好的事务能够使人心情预约,尤其是美丽的小姐姐哈哈哈,这篇文章是一篇爬虫实战,没有什么技术难点,主要使用BeautifulSoup库进行分析,重点讲解拿到一个网站时如何去分析页面源码. 1.用到 ...

  7. 三分钟教会你用Python爬取到喜欢的小姐姐图片

    使用Python爬取小姐姐图片 首先上网站链接 唯vb.net教程 美女生 爬取图片主要分为一下几步: 1.打开一个你喜欢c#教程的小姐姐的网站 E.g xiaojiejie web 2.下载并安装p ...

  8. Python爬虫实战:爬取YY上漂亮小姐姐视频

    目录 1.目标 2.确定数据所在的url 3.发送网络请求 4.数据解析 5.数据保存 6.爬取其他页数据 1.目标 本次目标是爬取YY(https://www.yy.com/)主页分类中小视频板块, ...

  9. C# POST——爬取B站直播时的弹幕

    打开b站,随便点进个直播,打开chrome自带的开发者工具,抓下包 妈耶-这封包还挺多的啊-慢慢的分析一会发现了这个 表面上看好像不是我们想要的,点开数据看了一下(⓿_⓿) 哎没错了就是这个,开撸代码 ...

最新文章

  1. 震惊!原来Android OpenGL ES可以这样用,实现 (水波纹)涟漪效果超惊艳!
  2. OpenGL stencil test模板测试的实例
  3. linux最常用的20条命令
  4. java socketchannel api,SocketChannel API
  5. zendstudio 默认网页打开your project的时候不显示本地主机localhost的解决方法
  6. 织梦CMS调用文章列表时,怎么显示短时间格式
  7. 运行aspnet时要求启用windows集成身份验证
  8. linux的abrt目录满了,linux:abrt-cli list
  9. mysql 子查询 性能_mysql子查询性能
  10. 电脑维修之——启动错误时的解决办法
  11. 企业污染排放数据库、海关数据库
  12. 大型企业数据库服务首选,AliSQL这几大企业级功能你了解几个?
  13. 【PAT】1105 Spiral Matrix(柳婼的思想详细解读)
  14. xxl-job 带参数执行和高可用部署
  15. Java中使用多态的好处和弊端及其举例
  16. Cocos2D-X Tutorial for iOS and Android: Getting Started
  17. ubuntu 安装小企鹅拼音输入法
  18. day01 HTMLCSS
  19. 20210209PC版微信 网络不可用,请检查你的网络设置 的解决方法
  20. 尾插法创建链表(C++代码)

热门文章

  1. [转]希腊字母的读音
  2. uniapp手写板,签字,签名
  3. 【华为机试真题二星题目 python】欢乐的周末_03
  4. SCI论文写作感悟(二版)
  5. html带颜色方块,HTML5 彩色方块组合动画
  6. 水运视频综合应用成套产品
  7. ipv6双栈技术是什么
  8. PS插件Photolemur 3 1.1.AI人工智能全自动中文版 支持CC2019
  9. win7系统调节鼠标灵敏度的方法分享
  10. 次时代游戏头发各项异性流光flowtexture绘制探析