0

I'm trying to get all the links from a web page. So far I have the page source stored in a string. I have done similar things like this in Java, using a string tokenizer. I've looked around trying to find something like this for C# but apparently it doesn't have this function. What would be the best way about going about this? I've found a split string method using delimiters, but that doesn't look very efficient. Any advice?

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by dickersonka
1

you are correct, String.split is the way to go to treat it the same as the tokenizer

the other way would be to use regex

0

regex is the easiest way to split it, theres many examples on how to split up html using regex out there.

0

Thanks. I just just found a way to get the links really easy.

private void toolStripButtonLinks_Click(object sender, EventArgs e)
        {
            foreach(HtmlElement link in webBrowser1.Document.Links)
            listViewLinks.Items.Add(link.GetAttribute("HREF").ToString());
        }

Now I just have to figure out how to check the links by getting the 220 response.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.