def parse_next(next): dbpurl = DbpUrl(next) # fetch html src = fetch_html(dbpurl.get_url()) html = Html(src, dbpurl) # download photoes photoes = html.get_photoes() dl_photos(get_photo_list(photoes)) next = html.next_url() if next: parse_next(next)
def parse_html(dbpurl): global counter # fetch html src = fetch_html(dbpurl.get_url()) html = Html(src, dbpurl) out_dir = html.get_title() # enter album cn_dirpath = make_dirs_cn(out_dir) os.chdir(cn_dirpath) # create album print(u2c('\n创建相册 ') + cn_dirpath) counter = 0 # download photoes = html.get_photoes() dl_photos(get_photo_list(photoes)) # continue download next = html.next_url() def parse_next(next): dbpurl = DbpUrl(next) # fetch html src = fetch_html(dbpurl.get_url()) html = Html(src, dbpurl) # download photoes photoes = html.get_photoes() dl_photos(get_photo_list(photoes)) next = html.next_url() if next: parse_next(next) if next: parse_next(next) # leave album os.chdir('..') u2c_print('下载总数 %d张' % counter)