All RapidShare Links Blogspot C#

This article has been written before more than 24months, information might old.

Imi trebuia ceva care sa poata culege toate linkurile de tip ” rapidshare ” de pe un blog hostat de Blogspot , ideea ar fi fost ca imediat ce am toate linkurile le pot verifica daca mai sunt inca valide , si m am gandit sa scriu repede un mini-tool pentru aceasta .

Sursa (c#) :

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
using System.Windows.Forms;

namespace BRLS
{
    public partial class fmain : Form
    {
        public fmain()
        {
            InitializeComponent();
        }

        public void az_GetContent(string strURL)
        {

            StringBuilder sb = new StringBuilder();
            byte[] buf = new byte[8192];
            HttpWebRequest request = (HttpWebRequest)
            WebRequest.Create(strURL + "/search?&max-results=999999999");
            HttpWebResponse response = (HttpWebResponse)
                request.GetResponse();
            Stream resStream = response.GetResponseStream();
            string tempString = null;
            int count = 0;
            do
            {
                count = resStream.Read(buf, 0, buf.Length);
                if (count != 0)
                {
                    tempString = Encoding.ASCII.GetString(buf, 0, count);
                    sb.Append(tempString);
                }
            }
            while (count > 0);

            string strFilePath,temp,tempname;
            temp = Path.GetTempPath().ToString();
            tempname = "aztake.txt";
            strFilePath = String.Concat(temp, tempname);
            StreamWriter oSw = new StreamWriter(strFilePath);
            oSw.WriteLine(sb.ToString());
            oSw.Close();
            
        }
        public void az_filer_wr()
        {
            
            string strFilePath, temp;
            temp = Path.GetTempPath().ToString();
            strFilePath = temp + "aztake.txt";
            StreamReader sr = new StreamReader(strFilePath);
            string ssr = sr.ReadToEnd();
            sr.Close();
            string sPattern = "http://rapidshare.com/([A-Za-z0-9/_-]*).zip";
            string strFilePath2;
            temp = Path.GetTempPath().ToString();
            strFilePath2 = temp + "azlist612.txt";
            StreamWriter sw = new StreamWriter(strFilePath2);




            //Instantiating Regex Object
            Regex re = new Regex(sPattern, RegexOptions.IgnoreCase);
            MatchCollection mc = re.Matches(ssr);
            foreach (Match mt in mc)
            {
                sw.WriteLine(mt.ToString());
            }
            sw.Close();
            
            

        }

        public void clean()
        {
            string temp, strFilePath1, strFilePath2;
            temp = Path.GetTempPath().ToString();
            strFilePath1 = temp + "aztake.txt";
            strFilePath2 = temp + "azlist612.txt";
            StreamReader azf = new StreamReader(strFilePath2);
            this.tx_result.Text = azf.ReadToEnd().ToString();
            azf.Close();
            File.Delete(strFilePath1);
            File.Delete(strFilePath2);
        }


        private void bn_do_Click(object sender, EventArgs e)
        {
            if( this.tx_site.Text.ToString() == null || this.tx_site.Text.ToString() == "" ) 
            {
            MessageBox.Show(" Please Enter your Blogspot url ");
            }
            else{

                az_GetContent(tx_site.Text.ToString());
                az_filer_wr();
                clean();
            }

        }
    }
}
Share the joy

Leave a Reply