C jak configure

Marzec 19, 2009

django – djangobook offline

Filed under: django,programowanie — erendil @ 4:08 pm
Tags: , ,

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()

Dodaj komentarz »

Brak komentarzy.

Kanał RSS z komentarzami do tego wpisu. Adres TrackBack

Dodaj komentarz

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Zmień )

Twitter picture

You are commenting using your Twitter account. Log Out / Zmień )

Facebook photo

You are commenting using your Facebook account. Log Out / Zmień )

Connecting to %s

Theme: Rubric. Blog na WordPress.com.

Follow

Otrzymuj każdy nowy wpis na swoją skrzynkę e-mail.