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?

Recommended Answers

All 4 Replies

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

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

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.

nice job man, much more rewarding when you find out how to do it, than when we just tell you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.