Wget is a very useful tool, however, I dont know how to use it in python. Below is my try but with no luck. Would you tell me the right way ? Thank you very much !!

I made a wwget.py

#!/usr/bin/python

import urllib2, urllib

img=wget("http://blog.freetimegears.com.tw/patrick/archives/Maple-tree.jpg")

Running in termial


:~/abc$ ./wwget.py
Traceback (most recent call last):
File "./wwget.py", line 5, in <module>
img=wget("http://blog.freetimegears.com.tw/patrick/archives/Maple-tree.jpg")
NameError: name 'wget' is not defined

Comments
Very good question, not one that you're probably going to easily track down by browsing the Python documentation.

Thx sneekula and linux. I have tried and seems it is quite easy using linux's script to get the job done. Thanks.

If you're attempting to download a file in Python, it's very simple:

import urllib, os

# if you comment out this line, it will download to the directory from which you run the script.
os.chdir('/directory/to/save/the/file/to')

url = 'http://www.mydomain.com/myfile.txt'
urllib.urlretrieve(url)
This question has already been answered. Start a new discussion instead.