Only log article_link if post was successful
This commit is contained in:
parent
73cd62b707
commit
ab6e68588e
1 changed files with 2 additions and 2 deletions
|
@ -21,13 +21,13 @@ for article in soup.find_all("span", class_ = "txt"):
|
||||||
|
|
||||||
if is_new_article:
|
if is_new_article:
|
||||||
print(article_link+" has not been seen, posting")
|
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_lookup = requests.get(kuow_base_url+article_link)
|
||||||
article_soup = BeautifulSoup(article_lookup.content, 'html.parser')
|
article_soup = BeautifulSoup(article_lookup.content, 'html.parser')
|
||||||
try:
|
try:
|
||||||
article_description = (article_soup.find("meta", attrs={"property": "description"})).attrs["content"].strip()
|
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")
|
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:
|
except:
|
||||||
print("Could not load a description/post this article")
|
print("Could not load a description/post this article")
|
||||||
|
|
Loading…
Reference in a new issue