Download Webpage with Python and Urllib

The Python Urllib Module is present by Default on your System so you can make a little Python Script you call to Read and Save a Local Copy of a Webpage.

Open for Edit a File named for example and insert this code

import urllib

# Ask for Target Url Input
url = raw_input("Enter the Target URL : ")
# Ask for File Name Input
fileName = raw_input("Enter the File Name: ")

# Add http:// to your Url Name
url = 'http://' + url
# Open Connection to the Target Url
# Open the Local File for Writing
myFile = open(fileName,'w')
# Store the Html Content in a File
for lines in sock.readlines():
# Close the Local File
# Close the Urllib Connection to your Url

Now on a Unix like System you should make your File Executable by:

sudo chmod +x

Next when you need to Download a Webpage you can Call your Python Script with:

python /path/To/

You Give Url and Filename to Save a Webpage Copy on your System.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer