Compare commits

..

No commits in common. "ad81825bfe1d8f3e94a06ce39fda426e2f0236dd" and "a48985a0b9502d6992bcc885edb87bc63ea342fc" have entirely different histories.

View file

@ -1,6 +1,5 @@
import json
from datetime import datetime
from json.decoder import JSONDecodeError
from typing import Optional
import requests
@ -71,7 +70,7 @@ with Session(engine) as session:
schema_org = json.loads(schema_org_scriptblock.text)
assert schema_org["@context"] == "http://schema.org"
last_updated_time = datetime.fromisoformat(schema_org["dateModified"])
except (AssertionError, JSONDecodeError):
except:
print(
"Could not find or load schema.org data for this post, looking up the meta published time"
)
@ -81,7 +80,7 @@ with Session(engine) as session:
"meta", attrs={"property": "article:published_time"}
)["content"]
)
except NameError:
except:
print("Could not find or load the meta published time for this post")
last_updated_time = datetime.now()
@ -107,14 +106,14 @@ with Session(engine) as session:
article_record.dfp_targeting_id = article_soup.find(
"script", {"class": "dfp_targeting", "data-key": "id"}
)["data-value"]
except NameError:
except:
print("Could not find or load IDs for this post")
try:
tags = article_soup.find(
"script", {"class": "dfp_targeting", "data-key": "tags"}
)["data-value"].split("|")
except NameError:
except:
print("Could not find or load any tags for this article")
tags = []
@ -142,7 +141,7 @@ with Session(engine) as session:
article_record.post_id = mastodon_post_result["id"]
else:
print("Article has already been posted")
except Exception:
except:
print("Could not load a description/post this article")
article_record.article_link = article_link