• Log in or sign up for an account here: https://www.sythe.org/login

Grand Exchange Parser

Darthatron

Massive Troll

Retired Sectional Moderator
Visual Basic Programmers
Joined
May 22, 2006
Sythe Gold
0
Messages
1,612
Age
35
Location
The internet.
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.

2cdy35d.png


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.
 
Code looks nice well done, you should post more in this category :).
 
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.
 
So this just shows the prices right? Not the variations
 
Runescape Gamblingrunescape gambling
Back
Top