fixed errors

This commit is contained in:
Linus E
2022-05-10 18:43:41 +02:00
parent a3172cc9c5
commit 9324573cde
3 changed files with 33 additions and 12 deletions

View File

@@ -10,6 +10,8 @@ import sys
import os
import requests
import helper_functions as hf
from newsapi import NewsApiClient
from dotenv import load_dotenv
@@ -68,13 +70,14 @@ def format_article(article):
Returns:
String: formatted article
"""
sourcename = article["source"]["name"]
headline = article["title"]
url = article["url"]
sourcename = hf.make_markdown_proof(article["source"]["name"]) # make attributes markdownv2 proof
headline = hf.make_markdown_proof(article["title"])
url = hf.make_markdown_proof(article["url"])
formatted_article = f"_{sourcename}_\n*{headline}*\n\n{url}" # formatting in Markdown syntax
return formatted_article
if __name__ == '__main__': # only execute if script is called directly -> for simple testing
print("this is a module and should not be run directly")