哔哩哔哩爬取器:以个人为中心

Overview

Open Bilibili Crawer

哔哩哔哩是一个信息非常丰富的社交平台,我们基于此构造社交网络。在该网络中,节点包括用户(up主),以及视频、专栏等创作产物;关系包括:用户之间,包括关注关系(following/follower),回复关系(评论区),转发关系(对视频or动态转发);用户对创作物,包括评论关系(包括评论文本),发弹幕关系(包括弹幕文本),点赞、投币关系等。创作物之间的关系也可以人为构建,比如所属同一类别分区,拥有50%以上的相同tag等。

综上,哔哩哔哩网络是一个信息丰富的异质网络。

我们尝试以一个人为中心,去爬取他的个人信息与创作物信息。通过对指定的一群人进行信息的爬取,我们就可以得到一张信息丰富的异质网络。所以,OBC(Open Bilibili Crawer)的输入是一个用户,或一组用户的id(mid)。

OBC目前封装了三类爬虫:==关系爬虫、个人信息爬虫和视频爬虫==。关系爬虫负责通过默认的following关系爬取用户之间的关系,构建基础用户网络;个人信息爬虫负责抓取用户尽量多的有价值信息,提供用户节点属性;视频爬虫负责爬取视频相关的文本信息与统计类信息,可以进一步丰富用户节点属性,也可以构建异质视频节点。

OBC构建的异质网络

1. 关系爬虫

由于B站限制,对自己以外的用户最多只能浏览100个关注者/粉丝,所以关系爬虫对每个用户最多爬取100个他的关注者。对于大V来说,关注者数量通常远小于粉丝的数量,所以这种采样方法可以尽量减少网络结构的偏差。该爬虫返回三元组的列表,字段包括:

字段名 含义 备注
from_nd 中心用户mid
to_nd 中心用户关注的用户mid
rel_type 默认为“following”

这样的含义是:from_nd关注了to_nd。

2. 个人信息爬虫

个人信息分散在多个接口中,我们爬取的个人信息字段包括:

字段名 含义 备注
nfollowing 关注者数量
nfollower 粉丝数量
uname 用户名
sex 性别 男 女 保密
sign 个人简介
level b站等级 0-6的整数
official 官方头衔 以、分隔的字符串,分隔后每个元素都是一个头衔
birthday 生日 MM-DD格式,如01-01
school 学校
profession 职业
video_view 视频总播放量
article_view 专栏总阅读量
nlike 总点赞数

还有视频投稿数等一些指标没有集成进来。不过这些应该足够作为节点属性了。

3. 视频爬虫

该爬虫首先找到个人最近投稿的最多50条视频,然后对每条视频抓取一些文本信息和统计量。视频条数可以扩充。

文本信息包括视频所属类别(typeid)和视频的标签(tag 、tid)。爬虫还会存储所有遇见过的标签的信息,包括标签的题目、tid、关注该标签的人数、使用过该标签的人数等。此外,只需要建立typeid和标签的关联就可以大致判断出typeid代表的分区类型。统计量包括视频播放量等一系列数值。此外,接口还提供了视频时长、视频发布时间等更多的指标,这些并没有集成进来。

目前,每个人的视频信息包括:

    "mid" : 359797,      //mid
    "video_type" : {     //对视频所属种类的统计,视频种类以typeid代表
        "138" : 44,
        "21" : 4,
        "240" : 1,
        "28" : 1
    },
    "video_tag" : {     //对视频的标签出现频次按照降序排列,最多存50个,标签以标签id(tid)代表,可以在全局存标签信息的数据中查找到对应的标签名
        "1711163" : 38,
        "1833" : 17,
        "7662089" : 11,
        "6497596" : 10,
        "13926" : 9,
        ...
        "19327" : 1,
        "34356" : 1
    },
    "video_stat" : [   // 列表,每个元素都是视频的一些统计信息,包括8个指标
        {
            "aid" : 848235319,
            "bvid" : "BV1ZL4y1872w",
            "view" : 84679,
            "danmaku" : 107,  // 弹幕数
            "reply" : 273,
            "favorite" : 299,
            "coin" : 302,
            "share" : 309,
            "like" : 5082,
            "his_rank" : 0  // 0以外越小越好
        }, 
        {
            "aid" : 848011693,
            "bvid" : "BV1aL4y1a77s",
            "view" : 3128993,
            "danmaku" : 1767,
            "reply" : 4511,
            "favorite" : 33329,
            "coin" : 21221,
            "share" : 46047,
            "like" : 177489,
            "his_rank" : 34
        }, 
        ...
        ]

可以这样利用视频信息:

  1. 对每个人取topK个标签,把标签编码为向量后作为用户节点的属性之一
  2. 取每个人的视频所属类别最多的那个类别(typeid)作为用户节点的标签,看成K类别的多分类问题
  3. 视频的统计量,每个指标取sum/mean/max作为用户节点属性的一个维度

每个标签的信息如下:

{
	"tid" : 1767558,
    "tag_name" : "VLOG日常",
    "subscribe" : 5225,  // 关注数
    "use" : 1447949,     // 使用数
    "feature" : 0
}

4. Future Work

OBC建立在已圈定一批用户的基础上,对这批用户构造信息丰富的网络结构。如何圈定用户不在OBC职能之内。

未来工作包括:

  1. 构造异质节点和边:目前虽然可以构造视频节点,但用户和视频之间只有”发布视频“一种关系,还没有办法增加其他”用户--视频“关系如点赞、评论等。
  2. 本网络能服务于哪些下游任务?需要我们和看到此项目的各位一同思考。
  3. 增强OBC性能:添加代理、多线程等。
Owner
Boshen Shi
Devoted to my true belief
Boshen Shi
淘宝茅台抢购最新优化版本,淘宝茅台秒杀,优化了茅台抢购线程队列

淘宝茅台抢购最新优化版本,淘宝茅台秒杀,优化了茅台抢购线程队列

MaoTai 118 Dec 16, 2022
A web Scraper for CSrankings.com that scrapes University and Faculty list for a particular country

A look into what we're building Demo.mp4 Prerequisites Python 3 Node v16+ Steps to run Create a virtual environment. Activate the virtual environment.

2 Jun 06, 2022
for those who dont want to pay $10/month for high school game footage with ads

nfhs-scraper Disclaimer: I am in no way responsible for what you choose to do with this script and guide. I do not endorse avoiding paywalls or any il

Conrad Crawford 5 Apr 12, 2022
Web scrapper para cotizar articulos

WebScrapper Este web scrapper esta desarrollado en python 3.10.0 para buscar en la pagina de cyber puerta articulos dentro del catalogo. El programa t

Jordan Gaona 1 Oct 27, 2021
A dead simple crawler to get books information from Douban.

Introduction A dead simple crawler to get books information from Douban. Pre-requesites Python 3 Install dependencies from requirements.txt (Optional)

Yun Wang 1 Jan 10, 2022
A social networking service scraper in Python

snscrape snscrape is a scraper for social networking services (SNS). It scrapes things like user profiles, hashtags, or searches and returns the disco

2.4k Jan 01, 2023
A spider for Universal Online Judge(UOJ) system, converting problem pages to PDFs.

Universal Online Judge Spider Introduction This is a spider for Universal Online Judge (UOJ) system (https://uoj.ac/). It also works for all other Onl

TriNitroTofu 1 Dec 07, 2021
News, full-text, and article metadata extraction in Python 3. Advanced docs:

Newspaper3k: Article scraping & curation Inspired by requests for its simplicity and powered by lxml for its speed: "Newspaper is an amazing python li

Lucas Ou-Yang 12.3k Jan 07, 2023
Web scraped S&P 500 Data from Wikipedia using Pandas and performed Exploratory Data Analysis on the data.

Web scraped S&P 500 Data from Wikipedia using Pandas and performed Exploratory Data Analysis on the data. Then used Yahoo Finance to get the related stock data and displayed them in the form of chart

Samrat Mitra 3 Sep 09, 2022
Luis M. Capdevielle 1 Jan 14, 2022
腾讯课堂,模拟登陆,获取课程信息,视频下载,视频解密。

腾讯课堂脚本 要学一些东西,但腾讯课堂不支持自定义变速,播放时有水印,且有些老师的课一遍不够看,于是这个脚本诞生了。 时间比较紧张,只会不定时修复重大bug。多线程下载之类的功能更新短期内不会有,如果你想一起完善这个脚本,欢迎pr 2020.5.22测试可用 使用方法 很简单,三部完成 下载代码,

163 Dec 30, 2022
A simple django-rest-framework api using web scraping

Apicell You can use this api to search in google, bing, pypi and subscene and get results Method : POST Parameter : query Example import request url =

Hesam N 1 Dec 19, 2021
Scrape plants scientific name information from Agroforestry Species Switchboard 2.0.

Agroforestry Species Switchboard 2.0 Scraper Scrape plants scientific name information from Species Switchboard 2.0. Requirements python = 3.10 (you

Mgs. M. Rizqi Fadhlurrahman 2 Dec 23, 2021
Python framework to scrape Pastebin pastes and analyze them

pastepwn - Paste-Scraping Python Framework Pastebin is a very helpful tool to store or rather share ascii encoded data online. In the world of OSINT,

Rico 105 Dec 29, 2022
让中国用户使用git从github下载的速度提高1000倍!

序言 github上有很多好项目,但是国内用户连github却非常的慢.每次都要用插件或者其他工具来解决. 这次自己做一个小工具,输入github原地址后,就可以自动替换为代理地址,方便大家更快速的下载. 安装 pip install cit 主要功能与用法 主要功能 change 将目标地址转换为

35 Aug 29, 2022
中国大学生在线 四史自动答题刷分(现仅支持英雄篇)

中国大学生在线 “四史”学习教育竞答 自动答题 刷分 (现仅支持英雄篇,已更新可用) 若对您有所帮助,记得点个Star 🌟 !!! 中国大学生在线 “四史”学习教育竞答 自动答题 刷分 (现仅支持英雄篇,已更新可用) 🥰 🥰 🥰 依赖 本项目依赖的第三方库: requests 在终端执行以下

XWhite 229 Dec 12, 2022
抢京东茅台脚本,定时自动触发,自动预约,自动停止

jd_maotai 抢京东茅台脚本,定时自动触发,自动预约,自动停止 小白信用 99.6,暂时还没抢到过,朋友 80 多抢到了一瓶,所以我感觉是跟信用分没啥关系,完全是看运气的。

Aruelius.L 117 Dec 22, 2022
simple http & https proxy scraper and checker

simple http & https proxy scraper and checker

Neospace 11 Nov 15, 2021
Script for scrape user data like "id,username,fullname,followers,tweets .. etc" by Twitter's search engine .

TwitterScraper Script for scrape user data like "id,username,fullname,followers,tweets .. etc" by Twitter's search engine . Screenshot Data Users Only

Remax Alghamdi 19 Nov 17, 2022
Html Content / Article Extractor, web scrapping lib in Python

Python-Goose - Article Extractor Intro Goose was originally an article extractor written in Java that has most recently (Aug2011) been converted to a

Xavier Grangier 3.8k Jan 02, 2023