So I am trying to grab member profile links from a forum and display them in a console app. What I want to do is grab all the links from the webpage and print them out.
Current I am getting the page source like so:
String source = WebClient.DownloadString("URL");
What I want to do is iterate through that string and find every string like this:
<h3 class='ipsType_subtitle'>
<strong><a href='http://www.website.org/community/user/8416-unreal/' title='View Profile'>!Unreal</a></strong>
</h3>
Then once i get that part, I want to get the url like so:
http://www.website.org/community/user/8416-unreal/
Current this is the code I have tried, it works. But only grabs one of the links:
WebClient c = new WebClient();
String members = c.DownloadString("http://www.powerbot.org/community/members/");
int times = Regex.Matches(members, "<h3 class='ipsType_subtitle'>").Count;
Console.WriteLine(times.ToString());
for (int i = 1; i < times; i++)
{
try
{
int start = members.IndexOf("<h3 class='ipsType_subtitle'>");
members = members.Substring(start, 500);
String[] next = members.ToString().Split(new string[] { "a href='" }, StringSplitOptions.None);
String[] link = next[1].Split(' ');
Console.WriteLine(link[0].Replace("'", ""));
}
catch(Exception e) { Console.WriteLine("Failed: " + e.ToString()); }
}
Console.Read();
Thanks.