Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6792595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:59:24+00:00 2026-05-26T17:59:24+00:00

What I want is, opening a Link from a Website (from HtmlContent) and get

  • 0

What I want is, opening a Link from a Website (from HtmlContent)
and get the Html of this new opened site..

Example: I have http://www.google.com, now I want to find all Links.
For each Link I want to have the HTMLContent of the new Site.

I do something like this:

foreach (String link in GetLinksFromWebsite(htmlContent))
            {
                using (var client = new WebClient())
                {
                    htmlContent = client.DownloadString("http://" + link);
                }

                foreach (Match treffer in istBildURL)
                {
                    string bildUrl = treffer.Groups[1].Value;
                    bildLinks.Add(bildUrl);
                }
            }




   public static List<String> GetLinksFromWebsite(string htmlSource)
    {
        string linkPattern = "<a href=\"(.*?)\">(.*?)</a>";
        MatchCollection linkMatches = Regex.Matches(htmlSource, linkPattern, RegexOptions.Singleline);
        List<string> linkContents = new List<string>();
        foreach (Match match in linkMatches)
        {
            linkContents.Add(match.Value);
        }
        return linkContents;
    }

The other problem is, that I only get Links, not Linkbuttons (ASP.NET)..
How can I solve the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:59:25+00:00Added an answer on May 26, 2026 at 5:59 pm

    Steps to follow:

    1. Download Html Agility Pack
    2. Reference the assembly you have downloaded in your project
    3. Throw everything that starts with the word regex or regular expression out from your project and which deals with parsing HTML (read this answer to better understand why). In your case this would be the contents of the GetLinksFromWebsite method.
    4. Replace what you have thrown away with a simple call to the Html Agility Pack parser.

    Here’s an example:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using HtmlAgilityPack;
    
    class Program
    {
        static void Main()
        {
            using (var client = new WebClient())
            {
                var htmlSource = client.DownloadString("http://www.stackoverflow.com");
                foreach (var item in GetLinksFromWebsite(htmlSource))
                {
                    // TODO: you could easily write a recursive function
                    // that will call itself here and retrieve the respective contents
                    // of the site ...
                    Console.WriteLine(item);
                }
            }
        }
    
        public static List<String> GetLinksFromWebsite(string htmlSource)
        {
            var doc = new HtmlDocument();
            doc.LoadHtml(htmlSource);
            return doc
                .DocumentNode
                .SelectNodes("//a[@href]")
                .Select(node => node.Attributes["href"].Value)
                .ToList();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm opening a new browser window from my site for some of the members.
I have an HTML table with a link in the first column. I want
I have a html link in which a modal window will be opened while
so i continue from this question YouTube: get youtube title+ image+description like facebook `
I am using javascript for opening a new window when clicked on the link.
i am using facebox that give help for opening box from link but i
I have a form submit, where it get the values from the form and
I want to overlay one image with another using CSS. An example of this
I have html page with 2 links like <a href=http://www.w3schools.com/>Visit W3Schools</a> <a href=http://www.w4schools.com/>Visit W4Schools</a>
i want to have a link in frame a and open in frame b

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.