当前位置:网站首页>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/
边栏推荐
- Redhat7 system root user password cracking
- Installation of CAD plug-ins and automatic loading of DLL and ARX
- If function of MySQL
- Final review (Day2)
- [teacher Zhao Yuqiang] MySQL flashback
- redis 无法远程连接问题。
- 2022.DAY592
- Apt update and apt upgrade commands - what is the difference?
- 大二困局(复盘)
- [teacher Zhao Yuqiang] use the catalog database of Oracle
猜你喜欢

Disruptor learning notes: basic use, core concepts and principles

Exception when introducing redistemplate: noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception
![[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram](/img/29/1644588927226a49d4b8815d8bc196.jpg)
[function explanation (Part 2)] | [function declaration and definition + function recursion] key analysis + code diagram

【一起上水硕系列】Day 10
![[teacher Zhao Yuqiang] index in mongodb (Part 1)](/img/2d/277ec737f2a7065831a19d036e61e1.jpg)
[teacher Zhao Yuqiang] index in mongodb (Part 1)

Bernoulli distribution, binomial distribution and Poisson distribution, and the relationship between maximum likelihood (incomplete)

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

Redhat7 system root user password cracking

Kubernetes resource object introduction and common commands (V) - (configmap)
![[advanced pointer (2)] | [function pointer, function pointer array, callback function] key analysis + code explanation](/img/9b/a309607c037b0a18ff6b234a866f9f.jpg)
[advanced pointer (2)] | [function pointer, function pointer array, callback function] key analysis + code explanation
随机推荐
最大似然估计,散度,交叉熵
Alibaba cloud OOS file upload
1. 兩數之和
2022.DAY592
Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation
How does win7 solve the problem that telnet is not an internal or external command
Beaucoup de CTO ont été tués aujourd'hui parce qu'il n'a pas fait d'affaires
【无标题】
Apt update and apt upgrade commands - what is the difference?
Crontab command usage
Txt document download save as solution
Qt读写Excel--QXlsx插入图表5
Final review (Day5)
Disruptor learning notes: basic use, core concepts and principles
2022.DAY592
伯努利分布,二项分布和泊松分布以及最大似然之间的关系(未完成)
Redhat7系统root用户密码破解
Life is a process of continuous learning
Installation du plug - in CAD et chargement automatique DLL, Arx
项目总结--04