Snippet 2 - mirrorWeb External Method
1 def mirror(murl):
2 import os, time
3 savePath = '/home/prudek/Zope/mirror'
4 numNames=[] # filenames expressed numerically
5 for filename in os.listdir(savePath):
6 if os.path.isdir(savePath+'/'+filename):
7 numNames.append(int(filename))
8 if numNames:
9 saveDir = str(max(numNames)+1)
10 else:
11 saveDir = '1'
12 murl=murl.strip()
13 cmd = '/home/prudek/usr/local/bin/wget -p -k -E -nd -nH -nv -P'+saveDir+' '+murl
14 os.chdir(savePath)
15 w,r,e = os.popen3(cmd)
16 w.close()
17 output=r.read()+e.read()
18 chunk = output.split(' -> ')[1]
19 chunk = chunk.split('\n')[0]
20 relURL = chunk[chunk.rfind('/')+1:chunk.rfind('"')]
21 output=''+output.replace('\n','
|