Jump to content

How to get webpage source code using C#?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
justanothernoob

justanothernoob

    Newbie

  • Members
  • PipPip
  • 22 posts
Hey. I am trying to get the source code of a website, but I have a problem:

The page source changes, bit the URL does not change. I am trying to get the source code of the page AFTER the user has logged into the website.

My program gets the source code, but it is the source code of the page before you log in. I am trying to get the source code AFTER logged in. How would I get the program to get this source code?

Here's the code I am using to get the source code.

 public void LoadWebsiteSourceCode()

        {

            

            string inputurl = webadpageurl;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(inputurl);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            StreamReader urlinputreader = new StreamReader(response.GetResponseStream());

            string urlsourcecode = urlinputreader.ReadToEnd();

            


            websitesourcecode = urlsourcecode;




        }



#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
In FireFox, right-click and select "View Page Source". Otherwise, you'll have to code your application to log in before getting the source.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users