How do I get direct URL of the .mp4 video using C#?

c# html-agility-pack video web-scraping windows-phone

Question

I need some kind of algorithm to take the link out of mp4engine.

Here is an example of a page I wish to delete.

In this instance, the desired output would be: http://mp4engine.com:182/d/a2chmyndcqqgkpskitclvbgu5pgwxve2vmlrdsctpwbte2flb4i4hrz6/.hack_Roots (Dub) Episode 001-360p.mp4.

I tried usingHtmlAgilityPack to get the player code, yet it'sp,a,c,k,e,d , but I can't get it to work within my C# Windows Phone 8.1 code. I considered using the Jurassic package to run the JS, but WinPhone 8.1 doesn't appear to support it.

This is the script I get from HAP:

<script type='text/javascript'>eval(function(p,a,c,k,e,d){while(c--    )if(k[c])p=p.replace(new RegExp('\\b'+c.toString(a)+'\\b','g'),k[c]);return p} ('15("14").13({f:"0://2.1:e/d/c/.b (a) 9 8- 7.6",12:"0://2.1/4/h.g",11:"0://2.1/i/10/z.y",x:"w",v:u,t:s,5:"0",r:"0://2.1/4/q /p",o:[{3:"n",m:"0://2.1/4/h.g"},{3:"l",k:{f:\'0://2.1:e/d/c/.b (a) 9 8- 7.6\',\'5\':\'0\'}},{3:"j"}],});',36,42,'http|com|mp4engine|type|player|provider|mp4|360p|001|Episode|Dub|hack_Roots|a2chmyndcqqgkpskitclvbgu5pgwxve2vmlrdsctpwbte2flb4i4hrz6||182|file|swf|jw6||download|config|html5|src|flash|modes|six|skins|skin|420|height|722|width|1484|duration|jpg|hahgl235zwv2|00000|image|flashplayer|setup|flvplayer|jwplayer'.split('|')))

Additionally, I tried using the built-in WebView Control:

WebView wv = new WebView();
//... navigation to string and all that
var res = await wv.InvokeScriptAsync("eval", null);

Sadly, the method produces a string that is empty (res = "" )

Additionally, I looked forbase64 I was looking for a decodeable string, but the website doesn't seem to offer one.

How can I get the video URL?

1
4
10/14/2015 2:25:11 PM

Popular Answer

HTMLAgilityPack only parses static HTML code; to get data, you must run dynamic content (javascript).

There are three options available to you:

1 - Include a javascript beautifier code in your c# code (here you can see an example: http://jsbeautifier.org/). You can extract the video url in this specific instance and just in yours since it is there, although this is unusual.

2 - Connecting to the website using a.net web browser and running javascript code to scrape the data; in this scenario, your application must be a Windows Form application.

3. Connecting to the website and running the javascript code to scrape the data using a headless browser. You might use the well-known phatomjs. Here's an illustration: Example of PhantomJS webdriver ExecutePhantomJS in C# for image filtering

0
5/23/2017 10:27:21 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow