Created
January 6, 2021 17:12
-
-
Save MrCirdo/12ba66848fb7d0a281995ca56dd38801 to your computer and use it in GitHub Desktop.
Petit script permettant de télécharger les scans de black clover.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import requests | |
from bs4 import BeautifulSoup | |
from rich import print | |
from rich.progress import track | |
def get_number_of_scan(chapter: int) -> int: | |
url = f"https://wwv.scan-1.com/black-clover/chapitre-{chapter}" | |
html = requests.get(url).text | |
soup = BeautifulSoup(html, features='lxml') | |
return len(soup.findAll('option')) | |
def download_all_scan(chapter: int, path: Path): | |
url = f'https://wwv.scan-1.com/uploads/manga/black-clover/chapters/chapitre-{chapter}/' | |
path /= f'chapter-{chapter}' | |
if not path.exists(): | |
path.mkdir() | |
n_scan = get_number_of_scan(chapter) | |
for i in track(range(1, n_scan + 1), f"Téléchargement du {chapter} chapitres :"): | |
complete_url = url + f'{i}.jpg' | |
if i < 10: | |
complete_url = url + f'0{i}.jpg' | |
r = requests.get(complete_url) | |
if r.status_code == 404: | |
return | |
complete_path = path / f'scans-{i}.jpg' | |
with complete_path.open('wb') as file: | |
file.write(r.content) | |
CHAPTER_MAX = 277 | |
CHAPTER_MIN = 1 | |
for i in range(CHAPTER_MIN, CHAPTER_MAX + 1): | |
download_all_scan(i, Path('.')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment