From ab6e68588e2e8e05cff31a6a2a983ab71e367d78 Mon Sep 17 00:00:00 2001 From: Liam Steckler Date: Sun, 14 Jan 2024 14:48:09 -0800 Subject: [PATCH] Only log article_link if post was successful --- kuow_fetcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kuow_fetcher.py b/kuow_fetcher.py index 2aacd17..05a558b 100644 --- a/kuow_fetcher.py +++ b/kuow_fetcher.py @@ -21,13 +21,13 @@ for article in soup.find_all("span", class_ = "txt"): if is_new_article: print(article_link+" has not been seen, posting") - with open(log_file, "a") as fp: - fp.write(article_link+"\n") article_lookup = requests.get(kuow_base_url+article_link) article_soup = BeautifulSoup(article_lookup.content, 'html.parser') try: article_description = (article_soup.find("meta", attrs={"property": "description"})).attrs["content"].strip() mastodon.status_post(status=article_description+"\n"+kuow_base_url+article_link+"\n#KUOW #News", visibility="unlisted") + with open(log_file, "a") as fp: + fp.write(article_link+"\n") except: print("Could not load a description/post this article") \ No newline at end of file