当前位置:网站首页>Top 100 video information of station B
Top 100 video information of station B
2022-06-11 04:48:00 【Panbohhhhh】
Write it at the front :
This is about b The reptile standing there .
It only represents personal practice . Welcome to discuss .
Practice is a process , The goal is to improve one's ability .
After recent contact with reptiles , For a moment, my hand itches , Intend to take the first step , As for why we climb b standing , The reason is not explained .
##1. preparation
Development environment personal choice Anaconda, The reason is that the library is really easy to install .

The library used in this article is very simple , Just two . Just install it yourself .
( By the way, I'll make complaints about it pycharm, It's really hard ... Maybe I'm not used to it .)
from bs4 import BeautifulSoup
from urllib import request
find bilibili Website :https://www.bilibili.com/ranking?spm_id_from=333.334.banner_link.1
Open it like this 
Press F12 have a look 
We'll soon find what we need , Approximate level ( why MD This one doesn't show ?)
graph LR
body-->div.app
div.app-->div.b-page-body
div.b-page-body-->div.main-inner
div.main-inner-->div.rank-container
div.rank-container-->div.rank-body
div.rank-body-->div.rank-list-wrap
div.rank-list-wrap-->ul.rank-list

I want to take something from here :
The initial idea is to output :
The ranking is :Num
URL The address is :XXXX
The name of the video is :XXXX
Play volume :XXX
Number of collections :XXX
author :XXX
starts .
Code work :
So here I'm going to use theta BeautifulSoup This package , Don't ask , Ask is the other will not .
headers = {
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36'
'(KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
}
url='https://www.bilibili.com/ranking?spm_id_from=333.334.banner_link.1'
req = request.Request(url, headers = headers)
X-Requested-With
add ’X-Requested-With’:‘XMLHttpRequest’
The returned data is json
No addition , The return data is normal html Text
It can be used to judge whether the client's request is Ajax Request or other request ..
User-Agent
User Agent The Chinese name is user agent , abbreviation UA, It's a special string header , Enables the server to identify the operating system and version used by the client 、CPU type 、 Browsers and versions 、 Browser rendering engine 、 Browser language 、 Browser plug-ins, etc .
common User-Agent Complete works of
About taking labels here , I use it beautifulsoup Of selector.
This one has CSS Selectors , filter find_all(),find(), wait , I'm also studying , At the same time, you can see the attached code , I tried a lot , It may be because of personal ability , The effect is not very good . If you have better , Also hope to share with me .
PS: As a programmer , Remember to write notes ....
Very brief , The result came out 
But there's a problem :
It's about img This piece of , I don't know b What has the station done ? I can't climb this string .
The image src=//i2.hdslb.com/bfs/archive/[email protected]_70h.webp
This paragraph can be copied into the browser for direct viewing .
I hope I can solve it later .
Code git Address :
Code
Because of my limited ability , There is inevitably a lack of understanding , Welcome to leave a message to discuss , Or talk to me directly .
边栏推荐
- 新库上线 | CnOpenData不可移动文物数据
- Problems in compiling core source cw32f030c8t6 with keil5
- tensorflow1. X and tensorflow2 Conversion of X
- Carbon path first, Huawei digital energy injects new momentum into the green development of Guangxi
- Crmeb/v4.4 Standard Version open version mall source code applet official account h5+app mall source code
- Mathematical basis of information and communication -- the first experiment
- lower_ bound,upper_ Bound, two points
- codesys 获取系统时间
- 华为设备配置BGP/MPLS IP 虚拟专用网地址空间重叠
- C语言试题三(程序选择题进阶_含知识点详解)
猜你喜欢

How to quickly find the official routine of STM32 Series MCU

Acts: how to hide defects?

Huawei equipment is configured with cross domain virtual private network

USB转232 转TTL概述

Free data | new library online | cnopendata data data of national heritage stores and auction enterprises

Meedu knowledge payment solution v4.5.4 source code

谷歌的代码覆盖率最佳实践

idea gradle项目 如何导入 本地jar 包

Network security construction in 5g Era

Yolact paper reading and analysis
随机推荐
Let me tell you how to choose a 10 Gigabit network card
数据中台和数据仓库有什么异同?
Decision tree (hunt, ID3, C4.5, cart)
QT method for generating QR code pictures
梅州二恶英实验室建设注意事项分享
tensorflow1. X and tensorflow2 Conversion of X
Programming Examples Using RDMA Verbs
Chia Tai International; What does a master account need to know
MindManager22专业版思维导图工具
Leetcode question brushing series - mode 2 (datastructure linked list) - 206:reverse linked list
[Transformer]MViTv1:Multiscale Vision Transformers
What is the KDM of digital movies?
智慧工地怎样做到数字化转型?
C语言试题三(语法选择题——含知识点详解)
Cartographer learning records: 3D slam part of cartographer source code (I)
CoDeSys get system time
PCB ground wire design_ Single point grounding_ Bobbin line bold
Differences between the four MQ
Analysis of hidden dangers in the construction of Fuzhou chemical laboratory
Lr-link Lianrui fully understands the server network card