当前位置:网站首页>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/
边栏推荐
- Crontab command usage
- [set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
- 期末复习(DAY7)
- Qt读写Excel--QXlsx插入图表5
- mapbox尝鲜值之云图动画
- Detailed explanation of iptables (1): iptables concept
- Method of finding prime number
- pytorch 多分类中的损失函数
- Configure DTD of XML file
- The server data is all gone! Thinking caused by a RAID5 crash
猜你喜欢

【一起上水硕系列】Day 10
![[video of Teacher Zhao Yuqiang's speech on wot] redis high performance cache and persistence](/img/a7/2140744ebad9f1dc0a609254cc618e.jpg)
[video of Teacher Zhao Yuqiang's speech on wot] redis high performance cache and persistence
![[function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation](/img/c2/991b8febd262cf9237017adc9d1221.jpg)
[function explanation (Part 1)] | | knowledge sorting + code analysis + graphic interpretation
![Together, Shangshui Shuo series] day 9](/img/39/c1ba1bac82b0ed110f36423263ffd0.png)
Together, Shangshui Shuo series] day 9

Code generator - single table query crud - generator

@Import annotation: four ways to import configuration classes & source code analysis

理解 YOLOV1 第一篇 预测阶段

Apache+php+mysql environment construction is super detailed!!!
![[teacher Zhao Yuqiang] index in mongodb (Part 1)](/img/2d/277ec737f2a7065831a19d036e61e1.jpg)
[teacher Zhao Yuqiang] index in mongodb (Part 1)

pytorch 搭建神经网络最简版
随机推荐
[teacher Zhao Yuqiang] Cassandra foundation of NoSQL database
今天很多 CTO 都是被幹掉的,因為他沒有成就業務
[teacher Zhao Yuqiang] MySQL flashback
最大似然估计,散度,交叉熵
Error 1045 (28000) occurs when Linux logs in MySQL: access denied for user 'root' @ 'localhost' (using password: yes)
期末复习(Day5)
PHP笔记超详细!!!
Common exceptions when Jenkins is released (continuous update...)
[escape character] [full of dry goods] super detailed explanation + code illustration!
JDBC connection database steps
Analysis of Clickhouse mergetree principle
[trivia of two-dimensional array application] | [simple version] [detailed steps + code]
[set theory] relational closure (reflexive closure | symmetric closure | transitive closure)
AtCoder Beginner Contest 258(A-D)
Installation du plug - in CAD et chargement automatique DLL, Arx
Complete set of C language file operation functions (super detailed)
Xaml gradient issue in uwp for some devices
Analysis of the example of network subnet division in secondary vocational school
There is no one of the necessary magic skills PXE for old drivers to install!!!
BeanDefinitionRegistryPostProcessor