ie webpage 2

R

RobcPettit

Hi, Can someone advise as to what Im doing wrong with this code.
public Form1()
{
InitializeComponent();
webBrowser1.Navigate("http://www.oddschecker.com/bet-
basket");

}
private void webBrowser1_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{

Text = webBrowser1.DocumentText;
stripdata st = new stripdata();
st.editdata(Text);
}

public class stripdata
{
public string[] contains = new string[] { "BX2", "BR", "BY",
"FR", "SO", "VC", "BS", "PP", "BT", "SK", "IG", "SJ", "PY", "LD",
"CE", "WH", "PN", "BF", "WB", "SI" };
public void editdata(string text)
{

string[] firstsplit = text.Split('<');
string[] secondsplit = new string[] { };
int y = 0;
for (int i = 0; i < firstsplit.Length; i++)
{
for (int x = 0; x < contains.Length; x++)
{
if (firstsplit.Contains(contains[x]))
{
secondsplit[y] = firstsplit;
y++;
}
}


}


}
Wha this does, with some help yesterday, Is load my oddschecker
bet basket into the webbrowser. Then it puts the document ttext int
Text, which is the passed to my class. The class then breaks the
string up by comparing it to an array. My problem is, I can get the
details to the class ok, and it starts of ok, but as soon as
if (firstsplit.Contains(contains[x]))
{
secondsplit[y] = firstsplit;
y++;
} = true and it adds the first value to
secondsplit(y) it finishes the for at thaat point. Ive tried f11
through it and it does the same, it doesnt complete the for. I hope
that makes sense. I dont get any exceptions, when debugging it just
shows the form again. I did try using a background thread, but couldnt
ge it to work, kept gettin an exception "Message="Exception has been
thrown by the target of an invocation."


Regards Robert
 
N

Nicholas Paldino [.NET/C# MVP]

I wouldn't be using this method to break apart the information that is
returned from you. Rather, I would try and find some distinct aspects in
the HTML (not the text) which you can use to identify your data, and then
work with that. For example, is this data stored in a table element? If
so, it would be easier to access the elements in the table structure rather
than parsing apart the text in the webpage.
 
R

RobcPettit

Thankyou for your reply. I will take your advice onbourd and read up
on HTML to see how you identify table elements.
Regards Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top