# checking if the images are correctly named. This is to prevent downloading us version of scan image_checker = root.rsplit('/', 6)[6] if re.search(r'^\d\d', image_checker): print('test') # creating the dir to put the images sorted by chapters dir_name = './images/' + manga.dir_name + '/' + chapter + '/' if not os.path.isdir(dir_name): os.mkdir(dir_name) # getting the generic link to the asset src = driver.find_element_by_id('image_scan').get_attribute( 'src').rsplit('/', 1)[0] # downloading all the pages for the chapter page = 0 for i in range(int(nb_pages) + 1): page_nb = "%02d" % page picture_name = manga.name + chapter + "_" + str(page) + ext # preventing missnamed files on the website (ie : 00.png instead of 01.png) response = requests.get(src + '/' + page_nb + ext) if response.status_code == 200: with open(dir_name + picture_name, "wb") as f: f.write( requests.get(src + '/' + page_nb + ext).content) page += 1 notifier.prepare(manga.name) print('pas de nouveau chapitres')