A cursory google search will reveal several scripts for retrieving rapidshare files using python, but each one I’ve seen delegates the actual retrieval to wget.
This is not necessary.
Rapidshare uses basic authentication to identify logged in members and urllib2 can handle this easily.
The following method would do the trick without the need to call external executables:
def rapidget(url. login, password):
"Retrieve files from rapidshare using only python"
request = urllib2.Request(url)
base64string = base64.encodestring('%s:%s' % (login, password))[:-1]
request.add_header("Authorization", "Basic %s" % base64string)
i = url.rfind('/')
filename = url[i+1:]
print url, "->", filename
file = open(filename, 'wb')
handle = urllib2.urlopen(request)
buffer = ''
buffersize = 1024*1024
while True:
buffer = handle.read(buffersize)
if not buffer:
handle.close()
file.close()
break
file.write(buffer)
buffer = ''
print '.',
This assumes, of course, that you have an account at rapidshare.