1 OUTPUT
= ['../', 'testsite1']
4 ' "betaManifestVersion": 1,',
5 ' "version": "version 1.0",',
19 from BeautifulSoup
import BeautifulSoup
21 print 'import failure'
23 #open manifest.json in OUTPUT for write
24 temp
= path
.path(OUTPUT
[0])
25 output
= temp
.joinpath(OUTPUT
[1])
26 absout
= os
.path
.abspath(output
)
27 print 'absout', absout
28 manifestname
= output
.joinpath('manifest.json')
29 manifest
= open(manifestname
, 'w')
30 for outlines
in PREFIX
:
31 manifest
.write(outlines
)
33 infile
= open('filelist.txt')
34 filelist
= infile
.readlines()
36 for filename
in filelist
:
37 page
= urllib2
.urlopen(filename
)
38 soup
= BeautifulSoup(page
)
39 temp
= soup
.prettify()
40 temp1
= temp
.replace('notloggedin', '')
41 pretty
= temp1
.replace('moodle', 'testsite1')
42 n
= filename
.find('moodle')
43 page
= path
.path(filename
[n
+7:-1])
45 fldrs
= page
.splitall()
46 print 'fldrs =', fldrs
47 for i
in range(1, len(fldrs
) - 1):
48 if not os
.path
.isdir(fldrs
[i
]):
49 print 'mkdir', fldrs
[i
]
53 temp
= page
.replace('.php', '')
54 realpage
= temp
.replace('?id=','') + '.html'
55 print 'page', page
, 'realpage', realpage
57 outfile
= open(realpage
, 'w')
58 print 'realpage', realpage
63 s
= ' { "url": "' + realpage
+ '" }'
65 if count
< len(filelist
):
70 for outlines
in SUFFIX
:
71 manifest
.write(outlines
)