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

  • SEARCH
  • Home
  • 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 8202717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:17:13+00:00 2026-06-07T07:17:13+00:00

I have the following code, however, when I launch it I only ever seam

  • 0

I have the following code, however, when I launch it I only ever seam to get a few URLS returned.

while (stopFlag != true)
{
    WebRequest request = WebRequest.Create(urlList[i]);
    using (WebResponse response = request.GetResponse())
    {
        using (StreamReader reader = new StreamReader
           (response.GetResponseStream(), Encoding.UTF8))
        {
            string sitecontent = reader.ReadToEnd();
            //add links to the list
            // process the content
            //clear the text box ready for the HTML code
            //Regex urlRx = new Regex(@"((https?|ftp|file)\://|www.)[A-Za-z0-9\.\-]+(/[A-Za-z0-9\?\&\=;\+!'\(\)\*\-\._~%]*)*", RegexOptions.IgnoreCase);
            Regex urlRx = new Regex(@"(?<url>(http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)", RegexOptions.IgnoreCase);

            MatchCollection matches = urlRx.Matches(sitecontent);
            foreach (Match match in matches)
            {
                string cleanMatch = cleanUP(match.Value);
                urlList.Add(cleanMatch);

                updateResults(theResults, "\"" + cleanMatch + "\",\n");

            }
        }
    }
}

I think the error is within the regex.

What I am trying to achieve is pull a webpage, then grab all the links from that page – add these to a list, then for each list item fetch the next page and repeat the process.

  • 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-06-07T07:17:16+00:00Added an answer on June 7, 2026 at 7:17 am

    Instead of trying to use regex to parse HTML, I suggest using a good HTML parser – the HTML Agilty Pack is a great choice:

    What is exactly the Html Agility Pack (HAP)?

    This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don’t HAVE to understand XPATH nor XSLT to use it, don’t worry…). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code however am getting the error Uncaught TypeError: Object #<addThis>
I have the following code below however am confused as to why the div
I have the following code that works without using throw however when I use
I have the following code: UPDATE myTable SET Col1 = @Value However, I have
I have the following code which works perfectly fine, however I would like to
I have the following code which deletes a record from a database. However I
I have the following code $result = $handle->select()->from('store_details') ->where('store_details.store_id=?', $id) ->columns('store_details.store_name'); //->query(ZEND_DB::FETCH_OBJ); However, when
I have following code which works fine, however when I updated to Lion I
I have following code to check a checkbox when user presses any key. However
I have the following code that I think should work - however, what I

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.