当前位置:网站首页>Simple solution of small up main lottery in station B
Simple solution of small up main lottery in station B
2022-07-03 05:57:00 【Leiqiu is the cutest】
B Station small UP Easy solution for the main lottery
B Station small UP Easy solution for the main lottery
Hello everyone , I am a b standing UP Lord A thunder hill , This is for me 2020 year 12 month 30 Japanese video 《 Easily solve small UP Main lottery puzzle 》 Project analysis for , Video address :https://www.bilibili.com/video/BV12A411p76j
B Station related API How to find and use
At the beginning of the project , My idea is to use requests The crawler crawls , Reuse beautifulsoup Analyze , The problem lies in b The front end of the station is dynamically rendered , There is no page switching , It's not easy to use reptiles ( Unless used selenium, But this is not suitable for the backend ). When I was distressed, I unexpectedly found a summary b standing API The article , While checking by yourself b After standing on the website structure, I found b The front-end information of the station is almost API To obtain the , For example, fan list , When you click it, you will have the... As shown in the figure API Access information .
Main function realization
The project is mainly composed of python To write , So choose requests Ku initiated API request ,json Library processing json data ,flask As the back end of web pages , The server side uses Nginx Reverse proxy from 80 Port proxy to intranet 5000 port .
1.BV No. reverse check AV Number
def BV2AV(bv_number):
url = f"https://api.bilibili.com/x/web-interface/view?bvid={bv_number}"
req = requests.get(url)
return json.loads(req.text)["data"]["aid"]
2.UID Check the user's nickname
def mid2username(mid):
url = f"https://api.bilibili.com/x/space/acc/info?mid={mid}&jsonp=jsonp"
req = requests.get(url)
name = json.loads(req.text)["data"]["name"]
return name
3. Get a list of all comments
def video_floor(bv_number):
av_number = BV2AV(bv_number)
page = 1
url = f"https://api.bilibili.com/x/v2/reply?&type=1&pn={page}&oid={av_number}"
req = requests.get(url)
json_file = json.loads(req.text)
all_comment = []
# Total comments
comment_number = json_file["data"]["page"]["count"]
# Count the number of comment pages
comment_page = comment_number // 20 + 1
for page in range(1, comment_page + 1):
url = f"https://api.bilibili.com/x/v2/reply?&type=1&pn={page}&oid={av_number}"
req = requests.get(url)
json_file = json.loads(req.text)
comments = json_file["data"]["replies"]
all_comment = all_comment + comments
return all_comment
4. Check UID Prevent repeated comments
def check_mid(all_comment):
MID_list = []
for each_comment in all_comment:
mid_tmp = each_comment["member"]["mid"]
if(MID_list.count(mid_tmp) == 0):
MID_list.append(mid_tmp)
return MID_list
5. Check if someone is paying attention UP Lord ( The function is not yet complete )
The reason why this function is not completed is B The site does not allow unrestricted access to the following list API, Only the first five pages can be accessed , After several visits, there was a ban IP act , Follow up b Is there anything else you can replace API, Otherwise, this function can only be a semi-finished product .
def check_subscibe(mid, up_mid):
print(f" Checking {mid} Are you paying attention to {up_mid}")
subscribe_list = []
flag = False
page = 1
url = f"https://api.bilibili.com/x/relation/followings?vmid={mid}&pn={page}&ps=20"
req = requests.get(url)
subscribe_number = json.loads(req.text)["data"]["total"]
page_number = subscribe_number // 50 + 1
for page in range(1, min(page_number + 1, 5)):
url = f"https://api.bilibili.com/x/relation/followings?vmid={mid}&pn={page}&ps=50"
req = requests.get(url)
json_tmp = json.loads(req.text)
if(json_tmp["data"]["list"] != None):
subscribe_list_tmp = json_tmp["data"]["list"]
subscribe_list += subscribe_list_tmp
for each_subscribe in subscribe_list:
if(each_subscribe["mid"] == up_mid):
flag = True
return flag
return flag
The overall situation of the project
To view the whole project, please move github,
Project address :https://github.com/Tessgraymane/bilibili_lottery/
边栏推荐
- ansible防火墙firewalld设置
- Yum is too slow to bear? That's because you didn't do it
- JDBC connection database steps
- Detailed explanation of contextclassloader
- AtCoder Beginner Contest 258(A-D)
- NG Textarea-auto-resize
- Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception
- Understand the first prediction stage of yolov1
- Solve the problem of automatic disconnection of SecureCRT timeout connection
- 2022.DAY592
猜你喜欢

中职网络子网划分例题解析

Strategy pattern: encapsulate changes and respond flexibly to changes in requirements

Life is a process of continuous learning

PHP notes are super detailed!!!
![Together, Shangshui Shuo series] day 9](/img/39/c1ba1bac82b0ed110f36423263ffd0.png)
Together, Shangshui Shuo series] day 9

今天很多 CTO 都是被幹掉的,因為他沒有成就業務

卷积神经网络CNN中的卷积操作详解

Simple handwritten ORM framework

多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)
![[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[teacher Zhao Yuqiang] Alibaba cloud big data ACP certified Alibaba big data product system
随机推荐
Core principles and source code analysis of disruptor
【一起上水硕系列】Day 7 内容+Day8
Understand expectations (mean / estimate) and variances
Error 1045 (28000) occurs when Linux logs in MySQL: access denied for user 'root' @ 'localhost' (using password: yes)
@Import annotation: four ways to import configuration classes & source code analysis
期末复习DAY8
理解 期望(均值/估计值)和方差
[written examination question analysis] | | get [sizeof and strlen] [pointer and array] graphic explanation + code analysis
[teacher Zhao Yuqiang] use the catalog database of Oracle
Download the corresponding version of chromedriver
NG Textarea-auto-resize
NG Textarea-auto-resize
[teacher Zhao Yuqiang] calculate aggregation using MapReduce in mongodb
1. Somme des deux nombres
Using the ethtool command by example
Common exceptions when Jenkins is released (continuous update...)
[set theory] relational closure (relational closure related theorem)
Redis encountered noauth authentication required
1. 两数之和
一起上水硕系列】Day 9