Adblock breaks this site

Grand Exchange Parser

Discussion in 'Programming General' started by Darthatron, Dec 7, 2011.

  1. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    Grand Exchange Parser

    Here's a pretty basic program I whipped up in like an hour to parse the Grand Exchange, and list items and stuff. Yeah, that's it.

    [​IMG]

    Code:
                listView1.Items.Clear();
                string ID, Name, Price, Change, Members;
                WebClient client = new WebClient();
                client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
                listView1.BeginUpdate();
                int CurrentPage = 0, PageCount = 0xFFFF;
                while (CurrentPage < PageCount)
                {
                    string Source = client.DownloadString("http://services.runescape.com/m=itemdb_rs/results.ws?page=" + (CurrentPage + 1).ToString() + "&query=" + txtSearch.Text + "&price=all&members=");
                    string[] ItemArray = Source.Split(new string[] { "<tr data-item-id=\"" }, System.StringSplitOptions.None);
                    if (PageCount == 0xFFFF)
                    {
                        PageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Source.Split(new string[] { "<em>" }, System.StringSplitOptions.None)[2].Split(new string[] { "</em>" }, System.StringSplitOptions.None)[0]) / 20));
                    }
                    this.Text = "Downloading page " + (CurrentPage + 1).ToString() + " of " + PageCount.ToString();
                    for (int i = 1; i <= ItemArray.Length - 1; i += 1)
                    {
                        ID = ItemArray[i].Split(new string[] { "\">" }, System.StringSplitOptions.None)[0];
                        Name = ItemArray[i].Split(new string[] { "alt=\"" }, System.StringSplitOptions.None)[1].Split('"')[0];
                        Price = ItemArray[i].Split(new string[] { "<td class=\"price\">" }, System.StringSplitOptions.None)[1].Split(new string[] { "</td>" }, System.StringSplitOptions.None)[0];
                        Change = ItemArray[i].Split(new string[] { "<td class=\"neutral\">", "<td class=\"positive\">", "<td class=\"negative\">" }, System.StringSplitOptions.None)[1].Split(new string[] { "</td>" }, System.StringSplitOptions.None)[0];
                        Members = ItemArray[i].Split(new string[] { "title=\"" }, System.StringSplitOptions.None)[1].Split(new string[] { "\">" }, System.StringSplitOptions.None)[0];
                        listView1.Items.Add(Name);
                        listView1.Items[listView1.Items.Count - 1].SubItems.Add(Price);
                        listView1.Items[listView1.Items.Count - 1].SubItems.Add(Change);
                        listView1.Items[listView1.Items.Count - 1].SubItems.Add(Members);
                        listView1.Items[listView1.Items.Count - 1].SubItems.Add(ID);
                    }
                    CurrentPage++;
                }
                listView1.EndUpdate();
    Slightly based off of this thread.

    The code should be relatively self-explanatory.
     
  2. iJava

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441
    Grand Exchange Parser

    Code looks nice well done, you should post more in this category :).
     
  3. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    Grand Exchange Parser

    Thanks it was my first shot at C# in ages. I've been only using C++ at university. Glad to see I haven't got any worse, I guess. :p

    I used to be a Programming Mod here, so I hope you aren't too shocked that I'm here.
     
  4. dongchan

    dongchan Member

    Joined:
    Apr 15, 2012
    Posts:
    82
    Referrals:
    0
    Sythe Gold:
    0
    Grand Exchange Parser

    would you like to sell all of your resourse code of it
     
  5. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    Grand Exchange Parser

    I don't understand.
     
  6. FranjuTheProd

    FranjuTheProd Newcomer
    Banned

    Joined:
    Apr 14, 2012
    Posts:
    24
    Referrals:
    0
    Sythe Gold:
    0
    Grand Exchange Parser

    Does this work for all the items of the ge?
     
  7. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    Grand Exchange Parser

    I don't see why not.
     
  8. Unanime

    Unanime Active Member
    Banned

    Joined:
    May 7, 2012
    Posts:
    194
    Referrals:
    0
    Sythe Gold:
    0
    Grand Exchange Parser

    So this just shows the prices right? Not the variations
     
  9. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    Grand Exchange Parser

    Right.
     
< [VB.NET][TUT] Winforms Desktop Numerical Clock "Gadget" | EAC PROOF counter strike 1.6 >


 
 
Adblock breaks this site