在不使用WebBrowser .NET控件的情况下获取Mediafire Directlink? [英] Getting mediafire directlink without using WebBrowser .NET control?

查看:123
本文介绍了在不使用WebBrowser .NET控件的情况下获取Mediafire Directlink?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找从Mediafire获得直接链接的方法.默认情况下,当用户访问下载链接时,将向他显示一个下载页面,在该页面中,他必须等待处理下载,然后会出现一个链接.

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.

我用WebBrowser WB搜索并找到了VB.NET 2008解决方案

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

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

它工作得很好,但是我对弹出窗口和加载速度感到厌倦.因此,我想知道是否有解决此问题的方法? (非WB解决方案^^)

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 ^^)

非常感谢您的帮助.

推荐答案

  • 如何使用以下方法发出Get请求 C#
  • 超出基础知识(处理cookie)
    • How to make a Get request using C#
    • Beyond the basics (Handling cookies)
    • 当我将正则表达式处理到代码中时,我将回发,尽管我认为实际链接是通过AJAX获得的,但不确定这是否能正常工作.我还在玩这个游戏.

      I'll be posting back when I've worked the regular expression into the code, not sure this is going to work though as I think the actual link is obtained through AJAX. I'm still playing with this.

      讨论过的AJAX问题:与StackOverflow相关的问题

      AJAX concerns discussed: StackOverflow related question

      基于注释中提供的php代码:

      Based on the php code provided in the comments:

      • 第一响应->获取传递的值 到一个叫做 "cG(var1,var2,var3)"我不认为 mediafire仍使用该功能, 好像是 现在"cu(var1,var2,var3)",不确定是否 您给的php仍然可以使用. 无论如何,我们可以做同样的事情 cu函数&中的值 将我们的请求发布到 http://www.mediafire.com/dynamic/download.php ? 与我们从我们获取的Cookie 第一个回应.
      • 第二反应创造了巨大的 随机生成的变量列表, 然后生成下载网址 串联其中的一些 变量,获取 使用使用 Microsoft.JScript引擎进行评估 此代码.我将发布我的 尽快编写代码
      • 1st Response->fetch the value passed to a function called "cG(var1,var2,var3)" I don't think mediafire still uses that function, it seems it's called "cu(var1,var2,var3)" now, not sure if the php you gave will still work. anyway, we can do the same thing get the values from the cu function & post our request to http://www.mediafire.com/dynamic/download.php? with the cookie we retrieved from our first response.
      • The 2nd response creates this huge list of random generated variables, then generates the download url concatenating some of those variables, the only way to get the url out if this is by using the Microsoft.JScript engine to evaluate this code. I'll be posting my code asap

      代码(警告该代码难看并且需要清除):

      Code (warning this code is ugly & needs to be cleaned up):

        string sURL = "http://www.mediafire.com/?syzjuytmdkn";
      
        HttpWebRequest wrGETURL = (HttpWebRequest)WebRequest.Create(sURL);
        wrGETURL.CookieContainer = new CookieContainer();
        wrGETURL.Referer = "http://www.mediafire.com";
        wrGETURL.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
      
        HttpWebResponse wrResponse = (HttpWebResponse)wrGETURL.GetResponse();
        CookieCollection cookies = wrResponse.Cookies;
      

      在此,我们发送第一个请求&存储收到的cookie.接下来,我们要分析页面以找出第二个请求的键:

      Here we send the first request & Store the cookies received. Next we want to parse the page to find out the keys for the 2nd request:

        StreamReader objReader = new StreamReader(wrResponse.GetResponseStream());
      
        string[] parameters = {};//will contain the parameters fetched
        string html = objReader.ReadToEnd();
        int cupos1 = html.IndexOf("cu(");
        int cupos2 = html.IndexOf("')",cupos1);
        string[] separators = { "','"};
      
        parameters = html.Substring(cupos1 + 4, cupos2 - cupos1 - 4)
                         .Split(separators, StringSplitOptions.None);
      

      获取第二页,其中将包含编码的下载网址:

      Fetch the 2nd page which will contain the encoded download url:

        string sURL2 = String.Format("http://www.mediafire.com/dynamic/download.php?qk={0}&pk={1}&r={2}",
                             parameters[0],parameters[1],parameters[2]);
      
        HttpWebRequest wrGETURL2 = (HttpWebRequest)WebRequest.Create(sURL2);
        wrGETURL2.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
        wrGETURL2.Referer = "http://www.mediafire.com";
      
        wrGETURL2.CookieContainer = new CookieContainer();
        wrGETURL2.CookieContainer.Add(cookies);
        wrResponse = (HttpWebResponse)wrGETURL2.GetResponse();
        objReader = new StreamReader(wrResponse.GetResponseStream());
        html = objReader.ReadToEnd();
      

      此html包含将生成下载网址的Javascript,此处我们将其提取,然后对其进行评估&最后将其写入控制台:

      This html contains the Javascript that will generate the download url, here we extract it, then evaluate it & finaly write it to the console:

        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());
      

      这东西对我有用,但是需要重写,我还保留了EvalJScript函数供您使用,就像我正在使用的一样(来自

      This stuff worked for me, but needs to be rewritten, I also leave the EvalJScript function for you to work as the one I'm using (from Evaluating JScript in c#) is deprecated

      这篇关于在不使用WebBrowser .NET控件的情况下获取Mediafire Directlink?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆