Hey im trying to get infomation from another website inside a <tbody> tag and there is around 20 - 25 things i need to get a hold on right now im some times getting dubbelt the same item and rarely getting all 20-25 items i need
im programming in MVC 3
my source code
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://eu.battle.net/d3/en/class/barbarian/active/");
//http://eu.battle.net/d3/en/class/wizard/active/
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
Regex retr = new Regex(@"<tr class=""([a-zA-Z0-9\s]+)"">");
Regex reLtd = new Regex(@"<td valign=""[a-zA-Z0-9]+"" class=""([a-zA-Z0-9\s-]+)"">");
Regex reLh4 = new Regex(@"<h4 class=""[a-zA-Z0-9\s]+"">([0-9]+)</h4>");
Regex reStd = new Regex(@"<td valign=""[a-zA-Z0-9]+"" class=""column-skill"">");
Regex reSdiv = new Regex(@"<div class=""skill-details"">");
Regex reSh4 = new Regex(@"<h4 class=""subcategory "">");
Regex reSa = new Regex(@"<a href=""([a-zA-Z0-9/-]+)"" rel=""np"">([a-zA-Z0-9\s]+)</a>");
Regex rectr = new Regex(@"</tr>");
Regex reEnd = new Regex(@"<tr class=""no-results");
int tr = 0;
int td = 0;
int h4 = 0;
int Std = 0;
int Sdiv = 0;
int Sh4 = 0;
int Sa = 0;
bool End = false;
ArrayList Level = new ArrayList();
ArrayList Spell = new ArrayList();
ArrayList Link = new ArrayList();
do
{
count = resStream.Read(buf,0,buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, buf.Length);
Match matr = retr.Match(tempString);
Match mactr = rectr.Match(tempString);
Match maLtd = reLtd.Match(tempString);
Match maLh4 = reLh4.Match(tempString);
Match maStd = reStd.Match(tempString);
Match maSdiv = reSdiv.Match(tempString);
Match maSh4 = reSh4.Match(tempString);
Match maSa = reSa.Match(tempString);
Match maEnd = reEnd.Match(tempString);
if (matr.Success && tr == 0 && End == false) {
tr += 1;
h4 = 0;
}
Kainore
0 Points
4 Posts
HttpwebRequest
Apr 18, 2012 12:48 AM|LINK
Hey im trying to get infomation from another website inside a <tbody> tag and there is around 20 - 25 things i need to get a hold on right now im some times getting dubbelt the same item and rarely getting all 20-25 items i need
im programming in MVC 3
my source code
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://eu.battle.net/d3/en/class/barbarian/active/");
//http://eu.battle.net/d3/en/class/wizard/active/
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
Regex retr = new Regex(@"<tr class=""([a-zA-Z0-9\s]+)"">");
Regex reLtd = new Regex(@"<td valign=""[a-zA-Z0-9]+"" class=""([a-zA-Z0-9\s-]+)"">");
Regex reLh4 = new Regex(@"<h4 class=""[a-zA-Z0-9\s]+"">([0-9]+)</h4>");
Regex reStd = new Regex(@"<td valign=""[a-zA-Z0-9]+"" class=""column-skill"">");
Regex reSdiv = new Regex(@"<div class=""skill-details"">");
Regex reSh4 = new Regex(@"<h4 class=""subcategory "">");
Regex reSa = new Regex(@"<a href=""([a-zA-Z0-9/-]+)"" rel=""np"">([a-zA-Z0-9\s]+)</a>");
Regex rectr = new Regex(@"</tr>");
Regex reEnd = new Regex(@"<tr class=""no-results");
int tr = 0;
int td = 0;
int h4 = 0;
int Std = 0;
int Sdiv = 0;
int Sh4 = 0;
int Sa = 0;
bool End = false;
ArrayList Level = new ArrayList();
ArrayList Spell = new ArrayList();
ArrayList Link = new ArrayList();
do
{
count = resStream.Read(buf,0,buf.Length);
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, buf.Length);
Match matr = retr.Match(tempString);
Match mactr = rectr.Match(tempString);
Match maLtd = reLtd.Match(tempString);
Match maLh4 = reLh4.Match(tempString);
Match maStd = reStd.Match(tempString);
Match maSdiv = reSdiv.Match(tempString);
Match maSh4 = reSh4.Match(tempString);
Match maSa = reSa.Match(tempString);
Match maEnd = reEnd.Match(tempString);
if (matr.Success && tr == 0 && End == false) {
tr += 1;
h4 = 0;
}
if (maLtd.Success && tr == 1 && td == 0)
{
td += 1;
}
if (maLh4.Success && tr == 1 && td == 1 && h4 == 0)
{
Level.Add(maLh4.Groups[1].Value);
h4 = 1;
//tr = 0;
//td = 0;
}
if (maStd.Success && tr == 1 && Std == 0)
{
Std += 1;
}
if (maSdiv.Success && Std == 1)
{
Sdiv = 1;
}
if (maSh4.Success && Sdiv == 1)
{
Sh4 = 1;
}
if (maSa.Success && Sh4 == 1 && tr == 1 && Sa == 0)
{
ViewBag.Spell = 4;
Sa += 1;
Spell.Add(maSa.Groups[2].Value);
Link.Add(maSa.Groups[1].Value);
}
if (mactr.Success && tr == 1)
{
tr = 0;
td = 0;
h4 = 0;
Std = 0;
Sdiv = 0;
Sh4 = 0;
Sa = 0;
}
if (maEnd.Success)
{
End = true;
}
sb.Append(tempString);
}
} while (count > 0);