获取
Bilibili的APP分享出来的链接是这样的
http://www.bilibili.com/video/BV1F5411W7Xs?share_medium=android&share_source=more&bbid=XY77F89744FCA2BD6727A13C62DF03F44BBF2&ts=1591426606873
我们看到分享链接后面的BV1F5411W7Xs这个视频的 BV号
是 1F5411W7Xs
而这条视频的直链是这样的
https://player.bilibili.com/player.html?aid=455956933&cid=199198887&page=1
访问下面链接(官方接口有失效可能)
https://api.bilibili.com/x/web-interface/view?bvid=BV号
获得一串json,从而获得这条视频的参数aid 俗称AV号
就是 455956933
、参数cid就是 199198887
最后就得到了上文的视频直链
挂载
网站添加CSS
/*视频挂载*/
.iframe_video {
position: relative;
width: 100%;
}
@media only screen and (max-width: 767px) {
.iframe_video {
height: 15em;
}
}
@media only screen and (min-width: 768px) and (max-width: 991px) {
.iframe_video {
height: 20em;
}
}
@media only screen and (min-width: 992px) and (max-width: 1199px) {
.iframe_video {
height: 30em;
}
}
@media only screen and (min-width: 1200px) {
.iframe_video {
height: 40em;
}
}
.iframe_cross {
position: relative;
width: 100%;
height: 0;
padding-bottom: 75%
}
.iframe_cross iframe {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0
}
挂载视频
合适的位置加入以下代码
<iframe class="iframe_video" src="//player.bilibili.com/player.html?aid=455956933&cid=199198887&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>
1 条评论
谢谢分享