473,466 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

htaccess & urllib

Is there a way to access an htaccess-protected directory with urllib,
password being known?
thanks,
max
--
========================================
Max Khesin, software developer -
ma*@cNvOiSsPiAoMntech.com
[check out our image compression software at www.cvisiontech.com, JBIG2-PDF
compression @
www.cvisiontech.com/cvistapdf.html]

Jul 18 '05 #1
3 7053
Max Khesin:
Is there a way to access an htaccess-protected directory with urllib,
password being known?


..htaccess is not a protection mechanism, but a configuration
file. If this configuration file specifies HTTP Basic
Authentication you can use:

"class FancyURLopener(...)
basic HTTP authentication is performed ...
Note: When performing basic authentication, a FancyURLopener
instance calls its prompt_user_passwd() method. The default
implementation asks the users for the required information on
the controlling terminal. A subclass may override this method to
support more appropriate behavior if needed."
http://www.python.org/doc/current/li...le-urllib.html

--
René Pijlman
Jul 18 '05 #2
thanks!

--
========================================
Max Khesin, software developer -
ma*@cNvOiSsPiAoMntech.com
[check out our image compression software at www.cvisiontech.com, JBIG2-PDF
compression @
www.cvisiontech.com/cvistapdf.html]
"Rene Pijlman" <re********************@my.address.is.invalid> wrote in
message news:tn********************************@4ax.com...
Max Khesin:
Is there a way to access an htaccess-protected directory with urllib,
password being known?


.htaccess is not a protection mechanism, but a configuration
file. If this configuration file specifies HTTP Basic
Authentication you can use:

"class FancyURLopener(...)
basic HTTP authentication is performed ...
Note: When performing basic authentication, a FancyURLopener
instance calls its prompt_user_passwd() method. The default
implementation asks the users for the required information on
the controlling terminal. A subclass may override this method to
support more appropriate behavior if needed."
http://www.python.org/doc/current/li...le-urllib.html

--
René Pijlman

Jul 18 '05 #3
"Max Khesin" <ma*@cNOvSisiPonAtecMh.com> writes:
Is there a way to access an htaccess-protected directory with urllib,
password being known?


urllib2 is better than urllib.

From the urllib2 module docstring, cut down a bit (and assuming you
mean basic HTTP authentication -- HTTPDigestAuthHandler might also be
of use to you):

import urllib2

authinfo = urllib2.HTTPBasicAuthHandler()
authinfo.add_password('realm', 'host', 'username', 'password')

opener = urllib2.build_opener(authinfo)

f = opener.open('http://www.python.org/')

print f.info() # response headers
print f.read() # response body
John
Jul 18 '05 #4

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

Similar topics

1
by: Chris Lyon | last post by:
I am running a medusa bases server, which spawns a copy process which reports back it's status using urllib as below try: f = urllib.urlopen("http://localhost:8088/root/copyresult" , params)...
8
by: Brad Tilley | last post by:
Probably a stupid question, but here goes: Is there any way to get a scaled down version of Python onto a Linksys Wireless router? Are there any projects out there that are doing this? I've...
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: Timothy Wu | last post by:
Hi, I'm trying to fill the form on page http://www.cbs.dtu.dk/services/TMHMM/ using urllib. There are two peculiarities. First of all, I am filling in incorrect key/value pairs in the...
3
by: Sanjay Arora | last post by:
We are looking to select the language & toolset more suitable for a project that requires getting data from several web-sites in real- time....html parsing/scraping. It would require full emulation...
9
by: James Stroud | last post by:
Hello All, I have been trying to make an https client with python, but it seems that, to do this, one needs to have the socket module compiled with ssl. This is not the default. So I have a...
7
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get...
1
by: Alessandro Fachin | last post by:
I write this simply code that should give me the access to private page with htaccess using a proxy, i don't known because it's wrong... import urllib,urllib2 #input url...
5
by: supercooper | last post by:
I am downloading images using the script below. Sometimes it will go for 10 mins, sometimes 2 hours before timing out with the following error: Traceback (most recent call last): File...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.