Grand Exchange Parser

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

Grand Exchange Parser
  1. Unread #1 - Dec 7, 2011 at 12:35 AM
  2. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    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.
     
  3. Unread #2 - Dec 9, 2011 at 4:48 AM
  4. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Grand Exchange Parser

    Code looks nice well done, you should post more in this category :).
     
  5. Unread #3 - Dec 10, 2011 at 1:05 AM
  6. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    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.
     
  7. Unread #4 - Apr 15, 2012 at 11:50 PM
  8. dongchan
    Joined:
    Apr 15, 2012
    Posts:
    82
    Referrals:
    0
    Sythe Gold:
    0

    dongchan Member

    Grand Exchange Parser

    would you like to sell all of your resourse code of it
     
  9. Unread #5 - Apr 16, 2012 at 12:59 AM
  10. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Grand Exchange Parser

    I don't understand.
     
  11. Unread #6 - Apr 16, 2012 at 3:35 PM
  12. FranjuTheProd
    Joined:
    Apr 14, 2012
    Posts:
    24
    Referrals:
    0
    Sythe Gold:
    0

    FranjuTheProd Newcomer
    Banned

    Grand Exchange Parser

    Does this work for all the items of the ge?
     
  13. Unread #7 - Apr 17, 2012 at 5:06 AM
  14. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Grand Exchange Parser

    I don't see why not.
     
  15. Unread #8 - May 17, 2012 at 9:54 PM
  16. Unanime
    Joined:
    May 7, 2012
    Posts:
    194
    Referrals:
    0
    Sythe Gold:
    0

    Unanime Active Member
    Banned

    Grand Exchange Parser

    So this just shows the prices right? Not the variations
     
  17. Unread #9 - May 20, 2012 at 9:40 AM
  18. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Grand Exchange Parser

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

Users viewing this thread
1 guest


 
 
Adblock breaks this site