Skip to content

Instantly share code, notes, and snippets.

@MrCirdo
Created January 6, 2021 17:12
Show Gist options
  • Save MrCirdo/12ba66848fb7d0a281995ca56dd38801 to your computer and use it in GitHub Desktop.
Save MrCirdo/12ba66848fb7d0a281995ca56dd38801 to your computer and use it in GitHub Desktop.
Petit script permettant de télécharger les scans de black clover.
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