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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:39:19+00:00 2026-05-23T00:39:19+00:00

It might sound silly; but can we programmatically login into a site such as

  • 0

It might sound silly; but can we programmatically login into a site such as Linkedin by passing our user credentials (userid and password)? I am not talking about using OAuth or other mechanism.

Edit:

I am using the following code in Page_Load method of an .aspx web page to login into Linkedin but it’s not working. I see the login page again:

  try {
      string url = "https://www.linkedin.com/uas/login";
      string userName = "SomeEmail@SomeDomain.Com";
      string password = "--------";
      string domain = "linkedin.com";
      string postData = "session_key=" + userName + "&session_password=" + password;
      string userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
      string method = "POST";
      string contentType = "text/html; charset=UTF-8";

      HttpWebRequest http = WebRequest.Create(url) as HttpWebRequest;

      http.UserAgent = userAgent;            
      http.Method = method;
      http.ContentType = contentType;            
      http.Credentials = new NetworkCredential(userName, password, domain);

      byte[] dataBytes = UTF8Encoding.UTF8.GetBytes(postData);
      http.ContentLength = dataBytes.Length;

      http.Timeout = -1;
      http.KeepAlive = true;
      http.CookieContainer = new CookieContainer();

      using (Stream postStream = http.GetRequestStream())
      {
         postStream.Write(dataBytes, 0, dataBytes.Length);
      }

      HttpWebResponse httpResponse = http.GetResponse() as HttpWebResponse;

      if (httpResponse.Cookies != null)
      {
         foreach (Cookie cok in httpResponse.Cookies)
         {
            if (cok != null)
            {
               Response.Write(String.Format("Name = {0}- Value = {1}- Path = {2}<br/>", cok.Name, cok.Value, cok.Path));
            }
         }
      }   

      Response.Write(httpResponse.Headers.ToString() + "<br/>");
      Response.Write(new StreamReader(httpResponse.GetResponseStream()).ReadToEnd());
  } catch(Exception ex) 
  { 
      Response.Write(ex.ToString());
  }
  • 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-23T00:39:20+00:00Added an answer on May 23, 2026 at 12:39 am

    You can login to many sites this way, using scripting. I generally prefer Python with BeautifulSoup, but there are many other possibilities for languages and libraries.

    The general idea is to locate the code for the form that has the username and password fields, fill them in, then post the form.

    This works for me on Linux, with my LinkedIn username and password in my .netrc in the standard format:

    #!/usr/bin/python
    import sys, os, urllib, urllib2, cookielib, urlparse, netrc
    from BeautifulSoup import BeautifulSoup
    URL = 'https://www.linkedin.com/uas/login'
    COOKIES = urllib2.HTTPCookieProcessor(cookielib.CookieJar())
    HANDLER = getattr(urllib2, urlparse.urlsplit(URL).scheme.upper() + 'Handler')
    DEBUGLEVEL = 0  # set to 1 to see unencrypted data
    OPENER = urllib2.build_opener(COOKIES, HANDLER(debuglevel = DEBUGLEVEL))
    def fetch(url, data = None):
     connection = OPENER.open(url, data)
     page = connection.read()
     connection.close()
     return page
    def login():
     soup = BeautifulSoup(fetch(URL))
     form = soup.find('form')
     fields = form.findAll('input')
     auth_info = netrc.netrc().authenticators(urlparse.urlsplit(URL).netloc)
     formdata = dict([[field['name'], field['value']] for field in fields])
     formdata['session_key'], ignored, formdata['session_password'] = auth_info
     assert form['method'] == 'POST'
     posturl = urlparse.urljoin(URL, form['action'])
     print fetch(posturl, urllib.urlencode(formdata))
    if __name__ == '__main__':
     login()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might sound like a silly question, but yesterday none of our sites would
That might sound silly but can't do it myself :( Need your help guys.
This might sound like a little bit of a crazy question, but how can
this might sound silly but since i am new to iPhone i wanted to
This might sound like a silly question but is there a manual or a
HI, this might sound like a silly question but.. i've created several types in
I know this might sound a silly question, but I did not find in
Ok, this might sound as a silly question, but I am a newbie without
I know that it might sound silly but, while working on project at some
I have a question with security point of view, it might sound silly but

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.