Króciutki skrypt w pythonie do zrobienia lokalnej kopii djangobook’a (http://djangobook.com/):
from BeautifulSoup import BeautifulSoup as Soup
from urllib import urlopen
Soup.QUOTE_TAGS['pre'] = None
plik=file('djangobook.html', 'w')
link = 'http://www.djangobook.com/en/2.0/' + 'chapter%02d/'
for i in range(1, 21):
#] + ['appendix%s/' % chr(i) for i in range(ord('A'), ord('I'))]:
print i
soup = Soup(urlopen(link % i))
content = soup.find('div', attrs={'class': 'yui-b'})
plik.write(content.renderContents())
link = 'http://www.djangobook.com/en/2.0/appendix%s/'
for i in 'ABCDEFGH':
#] + ['appendix%s/' % chr(i) for i in range(ord('A'), ord('I'))]:
print i
soup = Soup(urlopen(link % i))
content = soup.find('div', attrs={'class': 'yui-b'})
plik.write(content.renderContents())
plik.close()