-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
28 lines (25 loc) · 890 Bytes
/
main.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
import argparse
from scraper import Scraper
from common import init_config, TRY_AGAIN_STR
from extractor import Extractor
from formatter import Formatter
from saver import ContentSaver
"""
Short algo:
0st - initialize config
1st - get html with scrapper
2nd - clear tags and so on with extractor
3rd - format content with formatter
4th - save content with saver
"""
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--url", type=str, help="url to get readable context")
args = parser.parse_args()
if args.url:
config = init_config()
html = Scraper.get_content_in_html(args.url)
clear_content = Extractor(config).get_clear_content_from_html(html)
formatted_content = Formatter(config).get_formatted_content(clear_content)
ContentSaver.save_content(formatted_content, args.url)
else:
print(TRY_AGAIN_STR)