3 # Download all the LFS (development) tarballs from LFS page
9 class LFSPackParser(sgmllib
.SGMLParser
):
10 "LFS download page parser"
13 "Parse the given string 's'."
17 def __init__(self
, verbose
=0):
18 "Initialise an object, passing 'verbose' to the superclass."
19 sgmllib
.SGMLParser
.__init
__(self
, verbose
)
22 def start_a(self
, attributes
):
23 "Process a hyperlink and its 'attributes'."
25 for name
, value
in attributes
:
27 self
.hyperlinks
.append(value
)
29 def get_hyperlinks(self
):
30 "Return the list of hyperlinks."
31 return self
.hyperlinks
33 def get_page_contents():
34 page
= urllib
.urlopen("http://www.linuxfromscratch.org/lfs/view/development/chapter03/packages.html")
35 contents
= page
.read()
39 def get_package_list(page
):
40 parser
= LFSPackParser()
43 for name
in parser
.get_hyperlinks():
44 if name
.find('.tar') != -1:
49 page
= get_page_contents()
50 for name
in get_package_list(page
):
51 system("wget " + name
)
53 if __name__
== "__main__":