当前位置:网站首页>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/
边栏推荐
- Es 2022 officially released! What are the new features?
- [teacher Zhao Yuqiang] kubernetes' probe
- [teacher Zhao Yuqiang] use the catalog database of Oracle
- Core principles and source code analysis of disruptor
- NG Textarea-auto-resize
- [Zhao Yuqiang] deploy kubernetes cluster with binary package
- 2022.DAY592
- Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)
- Complete set of C language file operation functions (super detailed)
- 为什么网站打开速度慢?
猜你喜欢
Capacity expansion mechanism of map
Life is a process of continuous learning
Sophomore dilemma (resumption)
Redhat7系统root用户密码破解
Disruptor learning notes: basic use, core concepts and principles
Detailed explanation of contextclassloader
Convolution operation in convolution neural network CNN
[Shangshui Shuo series together] day 10
JDBC connection database steps
[function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation
随机推荐
2022.7.2day594
大二困局(复盘)
卷积神经网络CNN中的卷积操作详解
[escape character] [full of dry goods] super detailed explanation + code illustration!
Detailed explanation of findloadedclass
Today, many CTOs were killed because they didn't achieve business
BeanDefinitionRegistryPostProcessor
2022.7.2 模拟赛
Using the ethtool command by example
Redis encountered noauth authentication required
Sorry, this user does not exist!
[teacher Zhao Yuqiang] redis's slow query log
期末复习(Day5)
Final review (day3)
Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception
Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)
Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
期末复习DAY8
[teacher Zhao Yuqiang] the most detailed introduction to PostgreSQL architecture in history
Alibaba cloud Alipay sandbox payment