diff --git a/promptscrape.py b/promptscrape.py
index d236b15..2a2e3ae 100644
--- a/promptscrape.py
+++ b/promptscrape.py
@@ -1,4 +1,4 @@
-import requests, os
+import requests, os, re
from bs4 import BeautifulSoup
from datetime import date, datetime
@@ -29,12 +29,14 @@ centtheprompt = centprompttext.find("strong")
print("100words (100 words): \033[1m" + centtheprompt.text.lower() + "\033[0m (" + centprompt + ")\n")
thefile.write("- [[" + centprompt + "][100words]] (100 words): *" + centtheprompt.text.lower() + "*\n")
-# for this one we need to extract the right entry from a list, which may be an
but may not be
+# for this one we need to extract the right entry from a list, which may be an but may not be. also, need to use the right month, as next month’s prompts are posted in advance
today = int(date.today().strftime("%d"))
+month = str(date.today().strftime("%B"))
+monthstring = ".*" + month + ".*"
thirtyone = "https://31-days.dreamwidth.org/tag/!prompts?style=light&tag=%21prompts"
thirtyonepage = requests.get(thirtyone)
thirtyonesoup = BeautifulSoup(thirtyonepage.content, "html.parser")
-thirtyoneprompts = thirtyonesoup.find_all("h3", string=lambda text: "prompts" in text.lower())
+thirtyoneprompts = thirtyonesoup.find_all("h3", string = re.compile(monthstring))
thirtyonesubsoup = BeautifulSoup(str(thirtyoneprompts[0]), "html.parser")
thirtyoneurl = thirtyonesubsoup.find("a")
thirtyoneprompt = (thirtyoneurl["href"])
@@ -210,8 +212,9 @@ femslashpromptpage = requests.get(femslashpromptnew)
femslashpromptsoup = BeautifulSoup(femslashpromptpage.content, "html.parser")
femslashprompttext = femslashpromptsoup.find(class_="entry-content")
femslashtheprompt = femslashprompttext.find("i")
-print("femslash-ficlets (100–1000 words, F/F): \033[1m" + femslashtheprompt.text.lower() + "\033[0m (" + femslashprompt + ")\n")
-thefile.write("- [[" + femslashprompt + "][femslashficlets]] (100 words or a multiple of 100): *" + femslashtheprompt.text.lower() + "*\n")
+if femslashtheprompt is not None:
+ print("femslash-ficlets (100–1000 words, F/F): \033[1m" + femslashtheprompt.text.lower() + "\033[0m (" + femslashprompt + ")\n")
+ thefile.write("- [[" + femslashprompt + "][femslashficlets]] (100 words or a multiple of 100): *" + femslashtheprompt.text.lower() + "*\n")
with requests.Session() as s:
response = s.post(login_url , data)