from BeautifulSoup import BeautifulSoup as Soup
from urllib import urlopen

Soup.QUOTE_TAGS['pre'] = None

f=file('res.html', 'w')

base_url = 'http://www.djangobook.com/en/1.0/'


base_url = 'http://www.djangobook.com/en/1.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(base_url % i))
	content = soup.find('div', attrs={'class': 'yui-b'})

	f.write(content.renderContents())

base_url = 'http://www.djangobook.com/en/1.0/appendix%s/'

for i in 'ABCDEFGH':
#] + ['appendix%s/' % chr(i) for i in range(ord('A'), ord('I'))]:
	print i
	soup = Soup(urlopen(base_url % i))
	content = soup.find('div', attrs={'class': 'yui-b'})

	f.write(content.renderContents())

f.close()

