Advertisement
Guest User

Untitled

a guest
Dec 26th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.76 KB | None | 0 0
  1.  public class BillionUploads
  2.     {
  3.         #region WebHelper
  4.  
  5.         private static String GetRequest(String url)
  6.         {
  7.             var request = (HttpWebRequest)WebRequest.Create(url);
  8.             request.Method = "GET";
  9.        
  10.             HttpWebResponse response = null;
  11.             Stream responseStream = null;
  12.             StreamReader sr = null;
  13.  
  14.             response = (HttpWebResponse)request.GetResponse();        
  15.             responseStream = response.GetResponseStream();
  16.             sr = new StreamReader(responseStream, Encoding.Default);
  17.  
  18.             return sr.ReadToEnd();            
  19.         }
  20.  
  21.         private static String PostRequest(String url, Dictionary<string, string> postParameters)
  22.         {
  23.             string postData = "";
  24.  
  25.             foreach (string key in postParameters.Keys)
  26.                 postData += key + "=" + postParameters[key] + "&";
  27.  
  28.             postData = postData.Remove(postData.Length - 1, 1);
  29.  
  30.             var request = (HttpWebRequest)WebRequest.Create(url);
  31.             request.Method = "POST";
  32.             request.KeepAlive = true;
  33.             request.Referer = url;
  34.  
  35.             byte[] data = Encoding.ASCII.GetBytes(postData);
  36.             request.ContentLength = data.Length;
  37.  
  38.             HttpWebResponse response = null;
  39.             Stream requestStream = null;
  40.             Stream responseStream = null;
  41.             StreamReader sr = null;
  42.            
  43.             requestStream = request.GetRequestStream();
  44.             requestStream.Write(data, 0, data.Length);
  45.             requestStream.Close();
  46.  
  47.             response = (HttpWebResponse)request.GetResponse();
  48.             responseStream = response.GetResponseStream();
  49.             sr = new StreamReader(responseStream, Encoding.Default);
  50.  
  51.             return sr.ReadToEnd();        
  52.         }
  53.  
  54.         #endregion
  55.  
  56.         public static String GetDirectLink(String downloadLink)
  57.         {
  58.             String htmlCode = GetRequest(downloadLink);
  59.             String blader = Regex.Match(htmlCode, "hidden\">(.*)</textarea>").Groups[1].Value;
  60.             String id = Regex.Match(htmlCode, "name=\"id\" value=\"(.*)\">").Groups[1].Value;
  61.  
  62.             Dictionary<String, String> postParams = new Dictionary<string, string>();
  63.             postParams.Add("op", "download2");
  64.             postParams.Add("id", id);
  65.             postParams.Add("referer", "");
  66.             postParams.Add("method_free", "");
  67.             postParams.Add("method_premium", "");
  68.             postParams.Add("down_direct", "1");
  69.             postParams.Add("submit_btn", "");
  70.             postParams.Add("airman", "toast");
  71.             postParams.Add("blader", blader);
  72.  
  73.             htmlCode = PostRequest(downloadLink, postParams);
  74.  
  75.             return "";
  76.         }
  77.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement