diff --git a/promptscrape.py b/promptscrape.py index 078a23b..b4000d6 100644 --- a/promptscrape.py +++ b/promptscrape.py @@ -84,6 +84,8 @@ try: adstrippable = str(adtheprompt.text) while adstrippable[-1] == " ": adstrippable = adstrippable[:-1] + while adstrippable[0] == " ": + adstrippable = adstrippable[1:] print("anythingdrabble (100, 200, 300, 400, or 500 words): \033[1m" + adstrippable.lower() + "\033[0m (" + adprompt + ")\n") thefile.write("- [[" + adprompt + "][anythingdrabble]] (100, 200, 300, 400, or 500 words): *" + adstrippable.lower() + "*\n") except: @@ -124,6 +126,7 @@ try: zonetheprompt = zoneprompttext.find("strong") print("drabble-zone (100 or 200 words): \033[1m" + zonetheprompt.text.lower() + "\033[0m (" + zoneprompt + ")\n") thefile.write("- [[" + zoneprompt + "][drabble-zone]] (100 or 200 words): *" + zonetheprompt.text.lower() + "*\n") + emotion = "https://emotion100.dreamwidth.org/tag/*modpost?style=light&tag=%2Amodpost" emotionpage = s.get(emotion) emotionsoup = BeautifulSoup(emotionpage.content, "html.parser") @@ -146,7 +149,7 @@ try: ffa = "https://fail-fandomanon.dreamwidth.org/?style=light" ffapage = requests.get(ffa) ffasoup = BeautifulSoup(ffapage.content, "html.parser") - ffaprompts = ffasoup.find_all("h3", string=lambda text: "ffa dw post" in text.lower()) + ffaprompts = ffasoup.find_all("h3") ffapromptstrim = [x for x in ffaprompts if "Placeholder" not in str(x)] ffasubsoup = BeautifulSoup(str(ffapromptstrim[0]), "html.parser") ffaurl = ffasubsoup.find("a") @@ -210,7 +213,7 @@ try: flash = "https://fan-flashworks.dreamwidth.org/?style=light&tag=admin" flashpage = requests.get(flash) flashsoup = BeautifulSoup(flashpage.content, "html.parser") - flashprompts = flashsoup.find_all("h3", string=lambda text: "challenge" in text.lower()) + flashprompts = flashsoup.find_all(lambda tag: tag.name == "h3" and "Challenge" in tag.text) flashsubsoup = BeautifulSoup(str(flashprompts[0]), "html.parser") flashurl = flashsubsoup.find("a") flashprompt = (flashurl["href"]) @@ -224,24 +227,25 @@ try: except: pass -try: - femslash = "https://femslashficlets.dreamwidth.org/tag/challenges?style=light&tag=challenges" - femslashpage = requests.get(femslash) - femslashsoup = BeautifulSoup(femslashpage.content, "html.parser") - femslashprompts = femslashsoup.find_all("h3", string=lambda text: "challenge" in text.lower()) - femslashsubsoup = BeautifulSoup(str(femslashprompts[0]), "html.parser") - femslashurl = femslashsubsoup.find("a") - femslashprompt = (femslashurl["href"]) - femslashpromptnew = (femslashurl["href"] + "?style=light") - femslashpromptpage = requests.get(femslashpromptnew) - femslashpromptsoup = BeautifulSoup(femslashpromptpage.content, "html.parser") - femslashprompttext = femslashpromptsoup.find(class_="entry-content") - femslashtheprompt = femslashprompttext.find("i") - 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") -except: - pass +# seems dead +# try: +# femslash = "https://femslashficlets.dreamwidth.org/tag/challenges?style=light&tag=challenges" +# femslashpage = requests.get(femslash) +# femslashsoup = BeautifulSoup(femslashpage.content, "html.parser") +# femslashprompts = femslashsoup.find_all("h3", string=lambda text: "challenge" in text.lower()) +# femslashsubsoup = BeautifulSoup(str(femslashprompts[0]), "html.parser") +# femslashurl = femslashsubsoup.find("a") +# femslashprompt = (femslashurl["href"]) +# femslashpromptnew = (femslashurl["href"] + "?style=light") +# femslashpromptpage = requests.get(femslashpromptnew) +# femslashpromptsoup = BeautifulSoup(femslashpromptpage.content, "html.parser") +# femslashprompttext = femslashpromptsoup.find(class_="entry-content") +# femslashtheprompt = femslashprompttext.find("i") +# 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") +# except: +# pass try: with requests.Session() as s: @@ -339,98 +343,134 @@ try: except: pass -try: - if 30 > today > 21: - ssbingo = "https://sweetandshort.dreamwidth.org/tag/challenge:+bingo?style=light&tag=challenge:+bingo" - ssbingopage = requests.get(ssbingo) - ssbingosoup = BeautifulSoup(ssbingopage.content, "html.parser") - ssbingoprompts = ssbingosoup.find_all("h3") - ssbingosubsoup = BeautifulSoup(str(ssbingoprompts[0]), "html.parser") - ssbingourl = ssbingosubsoup.find("a") - ssbingoprompt = (ssbingourl["href"]) - ssbingopromptnew = (ssbingourl["href"] + "?style=light") - ssbingopromptpage = requests.get(ssbingopromptnew) - ssbingopromptsoup = BeautifulSoup(ssbingopromptpage.content, "html.parser") - ssbingoprompttext = ssbingopromptsoup.find(class_="entry-content") - ssbingotheprompt = ssbingoprompttext.find_all("td") - ssbingoclean = [] - for prompt in ssbingotheprompt: - newprompt = re.sub("<.*?>","",str(prompt)) - ssbingoclean.append(newprompt) - ssbingofinal = "; ".join(ssbingoclean).lower() - print("sweet and short bingo (up to 300 words for two prompts, up to 600 words for four prompts): \033[1m" + ssbingofinal + "\033[0m (" + ssbingoprompt + ")\n") - thefile.write("- [[" + ssbingoprompt + "][sweet and short bingo]] (up to 300 words for two prompts, up to 600 words for four prompts): *" + ssbingofinal + "*\n") -except: - pass +# sweet and short: complex and time-depedent rules … +# first need to work out which of the two alternating monthly challenges we're on -try: - if 16 > today > 7: - ssquicky = "https://sweetandshort.dreamwidth.org/tag/!new+challenge,challenge:+comment+quicky?mode=and&style=light&tag=%21new+challenge,challenge:+comment+quicky" - ssquickypage = requests.get(ssquicky) - ssquickysoup = BeautifulSoup(ssquickypage.content, "html.parser") - ssquickyprompts = ssquickysoup.find_all("h3") - ssquickysubsoup = BeautifulSoup(str(ssquickyprompts[0]), "html.parser") - ssquickyurl = ssquickysubsoup.find("a") - ssquickyprompt = (ssquickyurl["href"]) - # deliberately not using style=light here so we can get at the comment contents - ssquickypromptnew = (ssquickyurl["href"]) - ssquickypromptpage = requests.get(ssquickypromptnew) - ssquickypromptsoup = BeautifulSoup(ssquickypromptpage.content, "html.parser") - promptcatch = ".*New Prompts Here" - # ssquickytheprompt = ssquickypromptsoup.find_all("h4",string = re.compile(promptcatch)) - ssquickytheprompt = ssquickypromptsoup.find_all(class_="comment") - ssquickycomments = [] - for comment in ssquickytheprompt: - if re.search("New Prompts Here",str(comment)): - commenttext = re.findall(r"