-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.py
37 lines (26 loc) · 1.01 KB
/
examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def spip_example():
import xml.etree.ElementTree as ET
from pathlib import Path
from gemlog_from_rss.spip import MainPage, Page
import shutil
Path("resources").mkdir(parents=False, exist_ok=True)
main_page = MainPage(feed="http://lefaso.net/spip.php?page=backend")
Path(main_page.root_dir).mkdir(parents=False, exist_ok=True)
tree = ET.parse("resources/all_posts.xml")
root = tree.getroot()
main_page.root = root
about_page = Page(content_class="article_content")
about_page.download_html("https://lefaso.net/spip.php?article5736&rubrique17")
about_page.fetch_content()
main_page.add_page(about_page)
main_page.add_posts()
main_page.create_files()
with open(f"{main_page.root_dir}/index.gmi", "w") as f:
f.write(main_page.make_main_page())
# Remove temporary resources directory
try:
shutil.rmtree('resources')
except OSError as e:
print("Error: %s : %s" % ('resources', e.strerror))
def xml_example():
return None