urllib2

Python urllib2.urlopen bug: timeout error brings down my Internet connection?

I don't know if I'm doing something wrong, but I'm 100% sure it's the python script brings down my Internet connection. I wrote a python script to scrape thousands of files header info, mainly for Content-Length to get the exact size of each file, using HEAD request. Sample code: class HeadRequest(urllib2.Request): def get_method(...

For user-based and certificate-based authentication, do I want to use urllib, urllib2, or curl?

A few months ago, I hastily put together a Python program that hit my company's web services API. It worked in three different modes: 1) HTTP with no authentication 2) HTTP with user-name and password authentication 3) HTTPS with client certificate authentication I got 1) to work with urllib, but ran into problems with 2) and 3). Ins...

Why urllib2 doesn't work for me ?

I have installed 3 different python script on my ubuntu 10.04 32 bit machine with python 2.6.5. All of these use the urllib2 and I always get this error: urllib2.URLError: <urlopen error [Errno 110] Connection timed out> Why ? Examples: >>> import urllib2 >>> response = urllib2.urlopen("http://www.google.com") Traceback (most recen...

Python - default arguments in function

Looking at the python doc http://docs.python.org/library/urllib2.html urllib2.urlopen(url[, data][, timeout]) So, I pass in a url, then optional data and timeout variables (from how I read it). So if I want to pass a timeout, but not the data... whats the default variable for data? Do you just do, urlopen('http://www.example.com/', ,...

How do I download a zip file in python using urllib2?

Two part question. I am trying to download multiple archived Cory Doctorow podcasts from the internet archive. The old one's that do not come into my iTunes feed. I have written the script but the downloaded files are not properly formatted. Q1 - What do I change to download the zip mp3 files? Q2 - What is a better way to pass the varia...