public static void WhoIsOnline(string worldName, WhoIsOnlineReceived callback) { string url = "http://www.tibia.com/community/?subtopic=whoisonline&world=" + worldName; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.BeginGetResponse(delegate(IAsyncResult ar) { string html = GetHTML(ar); MatchCollection matches = Regex.Matches(html, @"<TD WIDTH=70%><[^<]*>([^<]*)</A></TD><TD WIDTH=10%>([^<]*)</TD><TD WIDTH=20%>([^<]*)</TD></TR>"); List<CharOnline> chars = new List<CharOnline>(matches.Count); CharOnline co; for(int i = 0; i < matches.Count; i++) { co = new CharOnline(); co.Name = Prepare(matches[i].Groups[1].Value); co.Level = int.Parse(matches[i].Groups[2].Value); co.Vocation = Prepare(matches[i].Groups[3].Value); chars.Add(co); } callback(chars); }, request); }
public static void WhoIsOnline(string worldName, WhoIsOnlineReceived callback) { string url = "http://www.tibia.com/community/?subtopic=whoisonline&world=" + worldName; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.BeginGetResponse(delegate(IAsyncResult ar) { string html = GetHTML(ar); MatchCollection matches = Regex.Matches(html, @"<TD WIDTH=70%><[^<]*>([^<]*)</A></TD><TD WIDTH=10%>([^<]*)</TD><TD WIDTH=20%>([^<]*)</TD></TR>"); List <CharOnline> chars = new List <CharOnline>(matches.Count); CharOnline co; for (int i = 0; i < matches.Count; i++) { co = new CharOnline(); co.Name = Prepare(matches[i].Groups[1].Value); co.Level = int.Parse(matches[i].Groups[2].Value); co.Vocation = Prepare(matches[i].Groups[3].Value); chars.Add(co); } callback(chars); }, request); }