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

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
Pseudo API for Google Trends

pytrends Introduction Unofficial API for Google Trends Allows simple interface for automating downloading of reports from Google Trends. Only good unt

General Mills 2.6k Dec 28, 2022
Extract gene TSS site form gencode/ensembl/gencode database GTF file and export bed format file.

GetTss python Package extract gene TSS site form gencode/ensembl/gencode database GTF file and export bed format file. Install $ pip install GetTss Us

laojunjun 6 Nov 21, 2022
This is a script that scrapes the longitude and latitude on food.grab.com

grab This is a script that scrapes the longitude and latitude for any restaurant in Manila on food.grab.com, location can be adjusted. Search Result p

0 Nov 22, 2021
A Python Covid-19 cases tracker that scrapes data off the web and presents the number of Cases, Recovered Cases, and Deaths that occurred because of the pandemic.

A Python Covid-19 cases tracker that scrapes data off the web and presents the number of Cases, Recovered Cases, and Deaths that occurred because of the pandemic.

Alex Papadopoulos 1 Nov 13, 2021
mlscraper: Scrape data from HTML pages automatically with Machine Learning

🤖 Scrape data from HTML websites automatically with Machine Learning

Karl Lorey 798 Dec 29, 2022
A web scraping pipeline project that retrieves TV and movie data from two sources, then transforms and stores data in a MySQL database.

New to Streaming Scraper An in-progress web scraping project built with Python, R, and SQL. The scraped data are movie and TV show information. The go

Charles Dungy 1 Mar 28, 2022
This is a module that I had created along with my friend. It's a basic web scraping module

QuickInfo PYPI link : https://pypi.org/project/quickinfo/ This is the library that you've all been searching for, it's built for developers and allows

OneBit 2 Dec 13, 2021
An arxiv spider

An Arxiv Spider 做为一个cser,杰出男孩深知内核对连接到计算机上的硬件设备进行管理的高效方式是中断而不是轮询。每当小伙伴发来一篇刚挂在arxiv上的”热乎“好文章时,杰出男孩都会感叹道:”师兄这是每天都挂在arxiv上呀,跑的好快~“。于是杰出男孩找了找 github,借鉴了一下其

Jie Liu 11 Sep 09, 2022
Google Scholar Web Scraping

Google Scholar Web Scraping This is a python script that asks for a user to input the url for a google scholar profile, and then it writes publication

Suzan M 1 Dec 12, 2021
A module for CME that spiders hashes across the domain with a given hash.

hash_spider A module for CME that spiders hashes across the domain with a given hash. Installation Simply copy hash_spider.py to your CME module folde

37 Sep 08, 2022
抢京东茅台脚本,定时自动触发,自动预约,自动停止

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

Aruelius.L 117 Dec 22, 2022
A list of Python Bots used to extract data from several websites

A list of Python Bots used to extract data from several websites. Data extraction is for products on e-commerce (ecommerce) websites. Data fetched i

Sahil Ladhani 1 Jan 14, 2022
Python script to check if there is any differences in responses of an application when the request comes from a search engine's crawler.

crawlersuseragents This Python script can be used to check if there is any differences in responses of an application when the request comes from a se

Podalirius 13 Dec 27, 2022
SmartScraper: 简单、自动、快捷的Python网络爬虫

SmartScraper: 简单、自动、快捷的Python网络爬虫 Note: The origin developer of SmartScraper is Alireza Mika, I only change a little code of AutoScraper. SmartScraper

DaDeng 9 Apr 16, 2022
Scrape data on SpaceX: Capsules, Rockets, Cores, Roadsters, SpaceX Info

SpaceX Sofware I developed software to scrape data on SpaceX: Capsules, Rockets, Cores, Roadsters, SpaceX Info to use the software you need Python a

Maxence Rémy 16 Aug 02, 2022
VG-Scraper is a python program using the module called BeautifulSoup which allows anyone to scrape something off an website. This program lets you put in a number trough an input and a number is 1 news article.

VG-Scraper VG-Scraper is a convinient program where you can find all the news articles instead of finding one yourself. Installing [Linux] Open a term

3 Feb 13, 2022
An utility library to scrape data from TikTok, Instagram, Twitch, Youtube, Twitter or Reddit in one line!

Social Media Scraper An utility library to scrape data from TikTok, Instagram, Twitch, Youtube, Twitter or Reddit in one line! Go to the website » Vie

2 Aug 03, 2022
Scrapping the data from each page of biocides listed on the BAUA website into a csv file

Scrapping the data from each page of biocides listed on the BAUA website into a csv file

Eric DE MARIA 1 Nov 30, 2021
A web crawler script that crawls the target website and lists its links

A web crawler script that crawls the target website and lists its links || A web crawler script that lists links by scanning the target website.

2 Apr 29, 2022
PS5 bot to find a console in france for chrismas 🎄🎅🏻 NOT FOR SCALPERS

Une PS5 pour Noël Python + Chrome --headless = une PS5 pour noël MacOS Installer chrome Tweaker le .yaml pour la listes sites a scrap et les criteres

Olivier Giniaux 3 Feb 13, 2022