This repository has been archived on 2024-02-23. You can view files and clone it, but cannot push or open issues or pull requests.
Auberge_Vagabonde/livres_fr.py
Michel Roux 3b5f58ddef
Some checks failed
continuous-integration/drone/push Build is failing
Add volume 3 FR and volume 8 EN
2021-05-18 14:21:51 +02:00

60 lines
1.4 KiB
Python

import os
import requests
from bs4 import BeautifulSoup
from pypub import Epub, create_chapter_from_string
if not os.path.exists('output'):
os.makedirs('output')
post = 0
url = 'https://www.jeunesecrivains.com/t53075p%s-the-wandering-inn-fan-traduction-fantastique-aventure'
volumes = [
None,
Epub("L'auberge Vagabonde - Volume 1", creator='Maroti, ElliVia', rights='Pirateaba', language='fr',
cover='cover.png'),
Epub("L'auberge Vagabonde - Volume 2", creator='Maroti, ElliVia', rights='Pirateaba', language='fr',
cover='cover.png')
]
for page in range(12):
html = requests.get(url % (page * 15))
soup = BeautifulSoup(html.text, 'html.parser')
tags = soup.select('div.postbody')
for tag in tags:
post = post + 1
if post <= 69:
volume = 1
elif post <= 168:
volume = 2
else:
volume = 3
if post == 1:
continue
title_test = tag.div.select_one('div[align=center]')
if not title_test:
continue
title = title_test.contents[0]
title_test.decompose()
text = tag.div.div
if text.get_text() == '':
text = tag.div
del text['style']
print(str(post) + ' - ' + title)
chapter = create_chapter_from_string(str(text), title)
volumes[volume].add_chapter(chapter)
volumes[1].create_epub('output')
volumes[2].create_epub('output')