#!/usr/bin/python # One obvious thing to do is apply error checking for url download, # download must contain at least one entry, and we are able to create the # new file. This will be done later. ### import the web module, string module, regular expression, module ### and the os module import urllib, string, re, os ### define the new webpage we create and where to get the info Download_Location = "/tmp/lthead.html" Url = "http://linuxtoday.com/backend/lthead.txt" #----------------------------------------------------------- ### Create a web object with the Url LinuxToday = urllib.urlopen( Url ) ### Grab all the info into an array (if big, change to do one line at a time) Text_Array = LinuxToday.readlines() New_File = open(Download_Location + "_new", 'w'); New_File.write("\n") New_File.close() ### If we have valid entries, move the new file to the real location if Entry_No > 0 : ### We could just do: ### os.rename(Download_Location + "_new", Download_Location) ### But here's how to do it with an external command. Command = "mv " + Download_Location + "_new " + Download_Location os.system( Command )