From 55b4492954a430b1d45f757db32953f6297898ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Thu, 14 Jul 2022 20:54:34 +0100 Subject: [PATCH] Add vocab-drabbles --- promptscrape.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/promptscrape.py b/promptscrape.py index 33e7cb1..f9f181b 100644 --- a/promptscrape.py +++ b/promptscrape.py @@ -258,3 +258,18 @@ ficletprompttext = ficletpromptsoup.find(class_="entry-content") ficlettheprompt = ficletprompttext.find("a") print("ficlet-zone (any): \033[1m" + ficlettheprompt.text.lower() + "\033[0m (" + ficletprompt + ")\n") thefile.write("- [[" + ficletprompt + "][ficlet-zone]] (any): *" + ficlettheprompt.text.lower() + "*\n") + +# slightly different format here, taking prompt from the post title +vocab = "https://vocab-drabbles.dreamwidth.org/?style=light&tag=challenge" +vocabpage = requests.get(vocab) +vocabsoup = BeautifulSoup(vocabpage.content, "html.parser") +vocabprompts = vocabsoup.find_all("h3") +vocabsubsoup = BeautifulSoup(str(vocabprompts[0]), "html.parser") +vocaburl = vocabsubsoup.find("a") +vocabprompt = (vocaburl["href"]) +vocabpromptnew = (vocaburl["href"] + "?style=light") +vocabpromptpage = requests.get(vocabpromptnew) +vocabpromptsoup = BeautifulSoup(vocabpromptpage.content, "html.parser") +vocabtheprompt = vocabpromptsoup.find(class_="entry-title") +print("vocab-drabbles (50–500 words): \033[1m" + vocabtheprompt.text.lower() + "\033[0m (" + vocabprompt + ")\n") +thefile.write("- [[" + vocabprompt + "][vocab-drabbles]] (50–500 words): *" + vocabtheprompt.text.lower() + "*\n")