views:

3147

answers:

5

I'm looking for the way to get the direct link from mediafire. By default, when a user visits a download link, he will be presented with a download page where he has to wait for the download to be processed and then a link will appear.

I googled and found a VB.NET 2008 solution to this using WebBrowser WB

http://www.vbforums.com/showthread.php?t=556681

It works pretty well but I'm tired of pop-up windows and the loading speed. So, I wonder if there is a solution to this problem? (a non WB solution ^^)

Any help is greatly appreciated.

+3  A: 
Vincent
There is a PHP solution but I don't know PHP, so I posting here in case someone need it. http://www.mysteryzillion.org/forums/showthread.php?t=4381
NVA
Vincent
Thanks, with your suggestion, I finally found the way to get the direct link using WebRequest :D. Thanks you again.
NVA
you're welcome, I just finished figuring it out as well. My code is ugle, do you mind posting some of your code?
Vincent
+1  A: 
Dim req As HttpWebRequest, res As HttpWebResponse
Dim cok As New CookieContainer, str As String, match As Match
req = WebRequest.Create("http://www.mediafire.com/?65d1dftjwml")
req.CookieContainer = cok
res = req.GetResponse
str = New StreamReader(res.GetResponseStream).ReadToEnd
match = Regex.Match(str, "cu\('(.+)','(.+)','(.+)'\);")
Dim qk As String = match.Groups(1).Value
Dim pk As String = match.Groups(2).Value
Dim r As String = match.Groups(3).Value
Dim t As String = "http://www.mediafire.com/dynamic/download.php?qk=" & qk & "&pk=" & pk & "&r=" & r & "&ukey=" & res.Cookies.Item("ukey").Value

req = WebRequest.Create(t)
res = req.GetResponse
txtcode.Text = New StreamReader(res.GetResponseStream).ReadToEnd
NVA
Here is my code to retrieve the huge list of of random generated variables. The following step is just like your code. Thanks you very much for helping me ^^
NVA
By accident, I found a little trick to get the final variables by using RegEX :D. var\s[a-z0-9]{6}='([a-z0-9]{11})';
NVA
Your code is much cleaner, thanks for sharing :)
Vincent
A: 

Hi thanks for the info. I've been pull my hair out trying to figure this mediafire downloads. I'm trying to developed a mod launcher for a game, and nearly considerd rehosting all the most to an easy to access server(alot of gigs). Ok, i've managed to get the final stage in vb.net but how do I "evaluated to generate the final url". Around 400 different var's are contained in the html after "". Please Help?

brok21k
Sorry didn't read this all. Im using VB.NET (I'll be going over to C# for my next project) which dosent have a eval() funtion. Just reading up on it :)
brok21k
A: 

This solution doesn't work anymore. Anybody have another suggestion ?

Thanks

jlezard
try mloader - sourcecode on codeplex http://mdownloader.codeplex.com/ (haven't tried it myself)
Vincent
A: 

the final block of code on my original answer is cut off - it shows the C# code on evaluating jscript:

  int varpos1 = html.IndexOf("<script language=\"Javascript\">")+35;
  //The variables are declared just before the 'function'
  int varpos2 = html.IndexOf("function",varpos1);
  string vardata = html.Substring(varpos1, varpos2 - varpos1);

  int hrefpos1 = html.IndexOf("href=\\\"http://", varpos2)+6 ;
  int hrefpos2 = html.IndexOf(">", hrefpos1);
  string hrefdata = String.Format("var url = {0};", html.Substring(hrefpos1, hrefpos2 - hrefpos1-5));
  object Result = EvalJScript(vardata + "\n" + hrefdata);
  Console.WriteLine(Result.ToString());
Vincent