473,394 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

urllib and login with passwords

Hey folks!

There are various web pages that I would like to read using urllib, but
they require login with passwords. Can anyone tell me how to find out
how to do that, both in general and specifically for YouTube.com.

Thankee.

Jul 26 '08 #1
2 7915
Jive Dadson wrote in news:Sv*********************@fe08.news.easynews.co m in
comp.lang.python:
Hey folks!

There are various web pages that I would like to read using urllib, but
they require login with passwords. Can anyone tell me how to find out
how to do that, both in general and specifically for YouTube.com.
A typical pattern is submit a form to login and get a cookie back,
subsuquent request with the cookie set are then "loged in".

import cookielib, urllib2

cj = cookielib.CookieJar()

opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(cj) )

page = opener.open( LOGIN_URL, data = LOGIN_FORM )
page.close()

page = opener.open( DOWNLOAD_URL )

print page.read()
page.close()
You will need to work out what goes in LOGIN_FORM, it likely
something like:

LOGIN_FORM = "username=name&password=pass&submit-button=Some+value"

where username, password and submit-button are the name of the
controls on the form you would normally login from.

If the form has an enctype='multipart/form-data' then things
get a little more complex, possibly start here:

http://aspn.activestate.com/ASPN/Coo.../Recipe/146306

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 26 '08 #2
Thanks, Rob! Some of that is beyond my maturity level, but I'll try to
figure it out. If anyone has specific info on about how YouTube does
it, I would appreciate the info.
Jul 26 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pieter Edelman | last post by:
Hi all, I'm trying to submit some data using a POST request to a HTTP server with BASIC authentication with python, but I can't get it to work. Since it's driving me completely nuts, so here's...
1
by: Larry | last post by:
Hi, my friends, As I know, service and start automatically even before user login. So If it's possible to create a service, make it running when system start , and record windows login password...
19
by: Siobhan | last post by:
Hi What is the recommended way to store a user's database credentials across the pages of a web application so that each time the database is accessed the system doesn't have to ask them for their...
2
by: seberino | last post by:
I finally figured out how to use the wonderful module urllib to download files. What if web page requires you to fill out a form with login and password first? Is this just like any other...
1
by: evanpmeth | last post by:
I have tried multiple ways of posting information to a website and have failed. I have seen this problem on other forums can someone explain or point me to information on how POST works through...
16
by: HMS Surprise | last post by:
I edited environment varialbes and have added C:\Python25\Lib to PYTHONPATH but get the no module message when the statement import urllib is executed. Even tried copying the urllib file to...
4
by: ldpfrog | last post by:
This is my first tutorial, so if there are any mistakes please forgive me =). This will show you a very simple way to read your Login information from an outside text file. What you need: 1....
0
by: gmguyx | last post by:
I tried using urllib.urlopen to open a personalized webpage (my.yahoo.com) but it doesn't work: print urllib.urlopen(http://my.yahoo.com).read() Instead of returning my.yahoo.com, it returns a...
0
by: johnpollard | last post by:
For some reason this script isn't working and I dont know what it is. I believe the problem lies in the following lines of code since the script works with a different website and username/password...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.