Reputation: 11
I have been struggling to get the streaming source of this video.
it is using jwplayer and i can see its source via chrome developer tools.
But is there any way i can scrape and get it programatically via php?Any help will be highly appreciated.
Upvotes: 1
Views: 29523
Reputation: 1094
Suppose you can execute javascript (selenium) and your script looks like:
<div id="myVideo"></div>
<script type="text/JavaScript">
var playerInstance = jwplayer("myVideo");
var countplayer = 1;
var countcheck = 0;
playerInstance.setup({
sources:[{file: 'https://video.xx.fbcdn.net/v/t42.9040-2/10000000_187709758618199_5004280148501987328_n.mp4?_nc_cat=0&efg=eyJybHIiOjE1MDAsInJsYSI6NDA5NiwidmVuY29kZV90YWciOiJzdmVfaGQifQ%3D%3D&rl=1500&vabr=571&oh=0bdc32a88a81edb15ea8470c6dc1b9fd&oe=5B00DA98',label: 'auto P','type' : 'mp4'}],
Then you can extract the url from the instance:
console.log(playerInstance.hls.url);
Upvotes: 0
Reputation: 420
No way. Getting it from the source is not possible everytime. Sometimes its hidden, and in this cases, you need to find the variable that difines the video url, usually something like :
*var video_url ="...*
So, you can open the page, play the video until it finishes, and on the console, run :
console.log(video_url);
This is fully functional, not fake .
Upvotes: 1
Reputation: 16838
The source for video is right there in the HTML of the page, in the script
section:
<div id="myVideo"></div>
<script type="text/JavaScript">
var playerInstance = jwplayer("myVideo");
var countplayer = 1;
var countcheck = 0;
playerInstance.setup({
sources:[{file: 'https://video.xx.fbcdn.net/v/t42.9040-2/10000000_187709758618199_5004280148501987328_n.mp4?_nc_cat=0&efg=eyJybHIiOjE1MDAsInJsYSI6NDA5NiwidmVuY29kZV90YWciOiJzdmVfaGQifQ%3D%3D&rl=1500&vabr=571&oh=0bdc32a88a81edb15ea8470c6dc1b9fd&oe=5B00DA98',label: 'auto P','type' : 'mp4'}],
You just have to get the file
value from the first sources
array.
preg_match("/sources:\[{file:\ '(.*?)'/s", $html, $match);
echo($match[1]);
gives the sought result:
https://video.xx.fbcdn.net/v/t42.9040-2/10000000_187709758618199_5004280148501987328_n.mp4?_nc_cat=0&efg=eyJybHIiOjE1MDAsInJsYSI6NDA5NiwidmVuY29kZV90YWciOiJzdmVfaGQifQ%3D%3D&rl=1500&vabr=571&oh=0bdc32a88a81edb15ea8470c6dc1b9fd&oe=5B00DA98
Upvotes: 3