[Release] Xtremetop100 Vote Comparer (W/ source)

08/29/2011 08:43 Zektor#1
[Only registered and activated users can see links. Click Here To Register...]

Download Binary & Source Code: [Only registered and activated users can see links. Click Here To Register...]

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Threading;
using System.Text.RegularExpressions;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        string[] links = new string[65535];
        string globallink = "http://www.xtremetop100.com/dekaron";
        int page = 0;
        public Form1()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
        }
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);
            if (e.CloseReason == CloseReason.WindowsShutDown)
            {
                return;
            }
            switch (MessageBox.Show(this, "Do you wish to close Vote Comparer?", "Exiting...", MessageBoxButtons.YesNo))
            {
                case DialogResult.No:
                    e.Cancel = true;
                    break;
                default:
                    Environment.Exit(0);
                    break;
            }
        }

        public string[,] reload()
        {
            WebClient client = new WebClient();
            String str = client.DownloadString(globallink);
            string[,] strArray = new string[500, 3];
            int cntr1 = 0, cntr2 = 0, cntr3 = 0;
            String insBanner = "<td class=\"stats1\"><br /><br /><b><span style=\"font-size: 12px; color: #000000;\">IN</span></b><br /> <span>";
            String outsBanner = "<td class=\"stats\"><br /><br /><b><span style=\"font-size: 12px; color: #000000;\">OUT</span></b><br /> <span>";
            String nameBanner = "style=\"text-decoration: none;\" rel=\"nofollow\">";
            String name = "<div id=\"middlebdba\"><a href=\"";
            String ins = "<div id=\"middlebdcb\">";
            String outs = "<div id=\"middlebdcC\">";
            foreach (string word in str.Split('\n'))
            {
                if (word.Contains(nameBanner))
                {
                    int a = word.IndexOf("rel=\"nofollow\">");
                    a += 15;
                    string newword = word.Substring(a, word.Length - a);
                    int b = newword.IndexOf("</a>");
                    newword = newword.Substring(0, b);
                    newword = "[Premium]" + newword;
                    strArray[cntr1, 0] = newword;
                    cntr1++;
                }
                else if (word.Contains(name))
                {
                    int a = word.IndexOf("rel=\"nofollow\">");
                    a += 15;
                    string newword = word.Substring(a, word.Length - a);
                    int b = newword.IndexOf("</a>");
                    newword = newword.Substring(0, b);
                    strArray[cntr1, 0] = newword;
                    cntr1++;
                }
                else if (word.Contains(insBanner))
                {
                    int a = word.IndexOf("<span>");
                    a += 6;
                    string newword = word.Substring(a, word.Length - a);
                    int b = newword.IndexOf("</span>");
                    newword = newword.Substring(0, b);
                    strArray[cntr2, 1] = newword;
                    cntr2++;
                }
                else if (word.Contains(ins))
                {
                    int a = word.IndexOf("<div id=\"middlebdcb\">");
                    a += 21;
                    string newword = word.Substring(a, word.Length - a);
                    int b = newword.IndexOf("</div>");
                    newword = newword.Substring(0, b);
                    strArray[cntr2, 1] = newword;
                    cntr2++;
                }
                else if (word.Contains(outsBanner))
                {
                    int a = word.IndexOf("<span>");
                    a += 6;
                    string newword = word.Substring(a, word.Length - a);
                    int b = newword.IndexOf("</span>");
                    newword = newword.Substring(0, b);
                    strArray[cntr3, 2] = newword;
                    cntr3++;
                }
                else if (word.Contains(outs))
                {
                    int a = word.IndexOf("<div id=\"middlebdcC\">");
                    a += 21;
                    string newword = word.Substring(a, word.Length - a);
                    int b = newword.IndexOf("</div>");
                    newword = newword.Substring(0, b);
                    strArray[cntr3, 2] = newword;
                    cntr3++;
                }
            }
            return strArray;
        }
        public bool refresh()
        {
            string[,] strArray = reload();
            label2.Text = "";
            label3.Text = "";
            label4.Text = "";
            label1.Text = "";
            int i = 0;
            this.label5.Location = new Point(label5.Location.X, 10);
            this.Height = 60;
            while (true)
            {
                if (strArray[i, 0] != null)
                {
                    label1.Text += "#" + (i + (50 * page) + 1) + "-" + strArray[i, 0] + "\r\n";
                    if (i == 0)
                    {
                        label2.Text += strArray[i, 1] + "\r\n";
                        label3.Text += strArray[i, 2] + "\r\n";
                        label4.Text += "\r\n";
                    }
                    else
                    {
                        int diffIns = Convert.ToInt32(strArray[i - 1, 1]) - Convert.ToInt32(strArray[i, 1]);
                        label2.Text += strArray[i, 1] + "\r\n";
                        label3.Text += strArray[i, 2] + "\r\n";
                        label4.Text += "+" + diffIns + "\r\n";
                    }
                    this.label5.Location = new Point(label5.Location.X, label5.Location.Y + 13);
                    this.Height += 13;
                }
                else
                {
                    break;
                }
                i++;
                if (i >= 50)
                {
                    button2.Enabled = true;
                }
                else
                {
                    button2.Enabled = false;
                }
            }
            label5.Text = "Last Updated: " + DateTime.Now;
            double Num;
            return double.TryParse(strArray[0, 1], out Num);
        }

        public void GenerateList()
        {
            WebClient client = new WebClient();
            String str = client.DownloadString("http://www.xtremetop100.com/");
            String cmp = "<div id=\"middleabgc\"><a href=\"/\" class=\"hei\">Show all</a>";
            foreach (string word in str.Split('\n'))
            {
                if (word.Contains(cmp))
                {
                    str = word;
                    break;
                }
            }
            string[] lines = Regex.Split(str, "class=\"hei\">");
            int combo = 0;
            foreach (string word in lines)
            {
                int aa = word.IndexOf("<a href=");
                String link = word.Substring(aa + 9, word.Length - (aa + 11));
                if (link.Length != 1)
                {
                    links[combo] = "http://www.xtremetop100.com/" + link;
                }
                else
                {
                    links[combo] = "http://www.xtremetop100.com/";
                }
                int a = word.IndexOf("</a>");
                if (a > 0)
                {
                    String newword = word.Substring(0, a);
                    comboBox1.Items.Add(newword);
                }
                combo++;
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            new Thread(delegate()
            {
                GenerateList();
                comboBox1.SelectedIndex = 0;
                while (true)
                {
                    Thread.Sleep(60000);
                    refresh();
                }
            }).Start();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            page = 0;
            label6.Text = "Page: " + (page + 1);
            globallink = links[comboBox1.SelectedIndex];
            refresh();
            button1.Enabled = false;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            button1.Enabled = true;
            page++;
            globallink = links[comboBox1.SelectedIndex] + "-" + (page * 50).ToString();
            if (refresh() == false)
            {
                page--;
                if (page <= 0)
                {
                    globallink = links[comboBox1.SelectedIndex];
                    button1.Enabled = false;
                }
                else
                {
                    globallink = links[comboBox1.SelectedIndex] + "-" + (page * 50).ToString();
                }
                refresh();
                button2.Enabled = false;
            }
            label6.Text = "Page: " + (page + 1);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (page > 1)
            {
                page--;
                globallink = links[comboBox1.SelectedIndex] + "-" + (page * 50).ToString();
                refresh();
                button2.Enabled = true;
            }
            else
            {
                page--;
                globallink = links[comboBox1.SelectedIndex];
                refresh();
                button1.Enabled = false;
            }
            label6.Text = "Page: " + (page + 1);
        }
    }
}
Enjoy Guys :D
08/29/2011 09:55 BigM'#2
Nice, but the right place is [Only registered and activated users can see links. Click Here To Register...]!
08/29/2011 13:38 Cholik#3
Use this thread for smaller releases: [Only registered and activated users can see links. Click Here To Register...]