简体   繁体   中英

How to extract all the current video files and its address in the web page with js?

 var imgs=document.images.length;

It can extract all the images on the web page.
How extract all the flv files whose suffix is flv such as sample.flv in the web page with js?Not all the flv files on my local directory but web page.
The plugin Video DownloadHelper in firefox can get the current mp4 file.
在此输入图像描述 Why my js code can't do the same task?

var Links = document.querySelectorAll('a[href$=".mp4"]');
console.log(Links);

在此输入图像描述

How to extract the current video files with js such as the plugin Video DownloadHelper in firefox?

Yahoo Movies use blob stream to transfer video data. There are no direct mp4/flv links anywhere, nor can you get such links directly. The src of the <video> tag refers to a blob stream link:

<video class="yvp-html5-video" preload="" id="2413371376" src="blob:https://www.yahoo.com/1dfafd99-a1ff-4cc8-bcff-255e69db9977"></video>

When you hit to download MP4 from Video DownloadHelper , the plugin actually reads the blob stream and writes it to disk in an MP4 file. It doesn't download a MP4 file. If you try to Copy URL , you'll get something like this to your clipboard:

https://roarack01.vpg.cdn.yimg.com/yahoomovies/61fb473f-04a2-381e-b2ae-9496dfba5e66_VYtMtix1DscECbXMT9tHT7yf2P9BZF-mRCMjBejFgALFHl7NSm1ZXPOMICAOr949v2xUgEASYLw-_1_0_vtt.m3u8?a=yahoomovies&ib=sapi&m=application%2fvnd.apple.mpegurl&mr=0&ns=c+i+ci+cii&vid=61fb473f-04a2-381e-b2ae-9496dfba5e66&x=1479599999&s=370695a7063b6aae06fb7f537c85773a

You can record a blob stream, but it's not an easy task.

For more details on video blob stream, check these links:

What is blob in the <video src=blob:url>?

Export HTML5 blob video to MP4

W3C Media Source Extensions

A URL for Blob and File reference

If I'm understanding correctly you want to look for all the links which have an associated .flv .

If you want this, you can use querySelectorAll and select all the links ending in .flv using the css selector $= .

var flvLinks = document.querySelectorAll('a[href$=".flv"]');

to get all flv files of a directory, please try the following code -

var files = fs.readdirSync("YOUR_DIRECTORY");
var path = require('path');

for(var i in files) {
   if(path.extname(files[i]) === ".flv") {
       //do your desired task here
   }
}

Hope it helps..:)

您可以在媒体子标签中的Chrome - >网络标签上检查所有视频请求。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM