Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-22-2005, 05:43 AM   #1 (permalink)
prashmohan
Registered User
 
Join Date: Nov 2005
Posts: 1
prashmohan is on a distinguished road
web log in using python

Hello

I am new to python programming. I want to do a project which calculates the broadband usage for a particular ISP. How can i get the pages after logging into a website?

i understand that i will have to use the urllib2 library. I have been trying to read the docs, but however i could not figure out how to use it's functions.

How can i pass username, password to a website and get the logged in webpage? also this site works only for IE, so i will have to set the user string too.

an equivalent code in perl is
$req = HTTP::Request->new( POST => $redir_base . "serviceResults.jsp" );
$req->content_type( 'application/x-www-form-urlencoded' );
$req->content( 'username=' . $username . '&queryDate=' . $year_month .
'&idAndName=&ispId=');

$res = $browser->request( $req );

How can I implement this in python?

Thank You

Prashanth
prashmohan is offline   Reply With Quote
Old 11-22-2005, 06:09 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Looks like you need to instantiate an HTTPBasicAuthHandler object to set your user name and password and call its build_opener and install_opener methods as in the 4th example here http://docs.python.org/lib/urllib2-examples.html . Then instatiate an HTTPRequest object and use the add_header method to set your user string.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 12-16-2005, 01:46 AM   #3 (permalink)
snowstar
Registered User
 
Join Date: Sep 2005
Posts: 4
snowstar is on a distinguished road
Thumbs up

Quote:
Originally Posted by teknomage1
Looks like you need to instantiate an HTTPBasicAuthHandler object to set your user name and password and call its build_opener and install_opener methods as in the 4th example here http://docs.python.org/lib/urllib2-examples.html . Then instatiate an HTTPRequest object and use the add_header method to set your user string.
snowstar is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Tutorial: Python Lists Overview sde Code Newbie News 3 03-24-2004 10:54 AM
So What Is Web Design? sde Lounge 9 07-06-2003 03:32 AM


All times are GMT -8. The time now is 03:30 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting