Michel Roux
230c5a76cf
All checks were successful
continuous-integration/drone/push Build is passing
52 lines
1.2 KiB
Python
52 lines
1.2 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", cover='cover.png'),
|
|
Epub("L'auberge Vagabonde - Volume 2", 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
|
|
volume = 1 if post <= 69 else 2
|
|
|
|
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(title)
|
|
|
|
chapter = create_chapter_from_string(str(text), title)
|
|
volumes[volume].add_chapter(chapter)
|
|
|
|
volumes[1].create_epub('output')
|
|
volumes[2].create_epub('output')
|