This commit is contained in:
2019-03-08 19:55:07 -08:00
parent 4b6ace88b1
commit 182d14fcaf
3 changed files with 52 additions and 13 deletions

View File

@@ -8,7 +8,7 @@ from goose3 import Goose
cgitb.enable()
goose = Goose({'enable_image_fetching': True})
goose = Goose()
def fetch_site(url):
return goose.extract(url=url)
@@ -17,14 +17,11 @@ def format_output(article):
with open('template.html', 'r') as f:
template = f.read()
extra = ""
if article.top_image:
extra += """<img src="{}" />""".format(article.top_image.src)
return template.format(
title=article.title,
body=article.cleaned_text,
extra=extra)
)
def print_headers():
print('Content-Type: text/html; charset=utf8\r\n\r\n')