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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:10:04+00:00 2026-05-31T07:10:04+00:00

I am trying to figure out how to login into a secure website in

  • 0

I am trying to figure out how to login into a secure website in order to parse user specific data and I can’t really find specific example of how to do so. I would like to write it in PHP but many of searches haven’t really turned up anything for that language. I’m familiar with Python and feel like maybe that would be of more use in this scenario. It also seems that many sites have API’s specific to that site to login. But searching and using specific API’s seems like more work for something I could write once then adapt.

For example: How could I login into stackoverflow programmatically and then parse my profile to fetch the total number of consecutive days i’ve logged in.

Using Simple_HTML_DOM I have written this which I’ve used before to parse non-secured html

<?php
include_once('simple_html_dom.php');
$html = file_get_html("http://stackoverflow.com/users/779920/nick");    
foreach($html->find('[class=days-visited]') as $e)
    echo $e->outertext . '<br>';
?>

But it doesn’t work in this case. I’m not sure if this is on the right track but I have tried familirized with POST data using firebug for Chrome but the tool is rather complex to me right now and I’m not exactly sure of how to properly decipher the data I’m given.

Any help would be appreciated.

  • 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-31T07:10:06+00:00Added an answer on May 31, 2026 at 7:10 am

    I think that it depends on exactly what system the page is using for authentication, but here is a snippet I used recently for exactly the same thing. In my case, I simply wanted to download the page:

    # An example website
    domain = 'http://secure.website.com'
    url = domain + '/web/page.html'
    # Create a new authentication handler
    auth_handler = urllib.request.HTTPBasicAuthHandler()
    # Set the login username and password
    auth_handler.add_password(None, domain, user='username', passwd='password')
    # Create and install a new opener for the handler
    opener = urllib.request.build_opener(auth_handler)
    urllib.request.install_opener(opener)
    # Connect to the page
    conn = urllib.request.urlopen(url)
    # Read all data on the webpage
    page = conn.readall().decode()
    # close the connection
    conn.close()
    

    I refer you to the urllib documentation (for python3. In python2 it is urllib2). It is reasonably well documented, although it took me a bit of trial and error to figure out the exact steps I needed. Note that the authentication handler only needs to handle to
    root you log into (in this case http://secure.website.com). Once you’ve installed the handler it will recognise any pages belonging to that domain and use the authentication information given. Also remember that this is not all that secure – anyone with access to the code will be able to see your login details.

    If you subsequently want to parse the webpage, you can use html.parser (or the python2 version, HTMLParser), or the much more powerful BeautifulSoup.

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

Sidebar

Related Questions

I'm trying to figure out how, after a user has opted into my Facebook
i'm trying to figure out how i can handle login protected actions in RoR
I'm trying to figure out what logic should go into the different UIViewController methods
Trying to figure out how I can do this properly. The print_r looks like
I'm trying to figure out the best way to insert content into a light
I'm trying to figure out to have multiple facebook accounts tied into my app.
I'm trying to figure out how to add in a remember me functionality into
I am stuck trying to figure out a way of checking if a user
I'm trying to figure out how should I integrate facebook login system in my
I'm trying to figure out the logic for creating tasks that have dependencies. In

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.