Remove trailing hashtags from social media captions.

This commit is contained in:
Suksi
2021-08-01 14:25:20 +03:00
parent b1e99bcb5d
commit 69f41a70dd
+4 -2
View File
@@ -1,4 +1,4 @@
import json, time, requests
import json, time, requests, re
def read_data_from_file(filename):
with open(filename, "r") as file:
@@ -41,7 +41,9 @@ def format_media(media):
# date format
timestamp = time.strptime(entry["timestamp"], "%Y-%m-%dT%H:%M:%S%z")
entry["timestamp"] = time.strftime("%d.%m.%Y", timestamp)
print(entry["timestamp"])
# remove hashtags from the ends of captions
entry["caption"] = re.sub("(\s?#\S+)*$", "", entry["caption"])
return media
def fetch_instagram_media():