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 8616337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:35:42+00:00 2026-06-12T05:35:42+00:00

I would like to grab some content from a website that is made with

  • 0

I would like to grab some content from a website that is made with Drupal.
The challenge here is that i need to login on this site before i can access the page i want to scrape. Is there a way to automate this login process in my C# code, so i can grab the secure content?

  • 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-12T05:35:43+00:00Added an answer on June 12, 2026 at 5:35 am

    To access the secured content, you’ll need to store and send cookies with every request to your server, starting with the request that sends your log in info and then saving the session cookie that the server gives you (which is your proof that you are who you say you are).

    You can use the System.Windows.Forms.WebBrowser for a less control but out-of-the-box solution that will handle cookies.

    My preferred method is to use System.Net.HttpWebRequest to send and receive all web data and then use the HtmlAgilityPack to parse the returned data into a Document Object Model (DOM) which can be easily read from.

    The trick to getting System.Net.HttpWebRequest to work is that you must create a long-lived System.Net.CookieContainer that will keep track of your log in info (and other things the server expects you to keep track of). The good news is that the HttpWebRequest will take care of all of this for you if you provide the container.

    You need a new HttpWebRequest for each call you make, so you must sets their .CookieContainer to the same object every time. Here is an example:

    UNTESTED

    using System.Net;
    
    public void TestConnect()
    {
        CookieContainer cookieJar = new CookieContainer();
    
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.mysite.com/login.htm");
        request.CookieContainer = cookieJar;
        HttpWebResponse response = (HttpWebResponse) request.GetResponse();
    
        // do page parsing and request setting here
        request = (HttpWebRequest)WebRequest.Create("http://www.mysite.com/submit_login.htm");
        // add specific page parameters here
        request.CookeContainer = cookieJar;
        response = (HttpWebResponse) request.GetResponse();
    
        request = (HttpWebRequest)WebRequest.Create("http://www.mysite.com/secured_page.htm");
        request.CookeContainer = cookieJar;
        // this will now work since you have saved your authentication cookies in 'cookieJar'
        response = (HttpWebResponse) request.GetResponse();
    }
    

    http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx

    HttpWebRequest Class

    http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.cookiecontainer.aspx

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

Sidebar

Related Questions

I m using codeigniter and would like to grab some user info with ajax.
I would like to embed some C# .Net code that does some simple Encryption/Decryption
I would like to grab a pki certificate when a request happens in jersey
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
Would like a for loop in jquery so that: For every hover_link: show hidden
Would like to make anapplication in Java that will not automatically parse parameters used
i have some VB that uses DAO to grab some data, one field being
i need a little bit of help with some jquery thing that i'm sure
I have an asp.net website which contains a few pages that I'd like to
hello there :) Im trying to figure out how i can grab some content

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.