aboutsummaryrefslogtreecommitdiffstats
path: root/app/utils.py
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2023-09-22 18:38:15 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2023-09-22 18:38:15 +0300
commit4844c3f4baf97d9ef7a194ab1f24ce922b927b7b (patch)
treeda2606cdc821da7c83028dd2d14dc6c01ace4dd1 /app/utils.py
parentcc8680564d259313042b211c0d40fa818b32059a (diff)
Improve scraper errors
Diffstat (limited to 'app/utils.py')
-rw-r--r--app/utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/utils.py b/app/utils.py
index 5401c5c..8dc4972 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -50,3 +50,11 @@ def item_to_dict(item: Item) -> ItemDict:
def dict_to_item(d: ItemDict) -> Item:
pub_date, rest = (lambda pub_date, **rest: (pub_date, rest))(**d) # type: ignore
return Item(pub_date=datetime.fromisoformat(pub_date), **rest) # type: ignore
+
+
+def dump_to_file(prefix: str, text: str):
+ now = datetime.now().isoformat()
+ dump_file_name = f"dump/{prefix}__{now}"
+ with open(dump_file_name, "w") as f:
+ f.write(text)
+ return dump_file_name