Switch to yaml config

This commit is contained in:
Liam Steckler 2024-01-14 15:12:33 -08:00
parent fde9904d8a
commit f901c89a64

View file

@ -1,4 +1,5 @@
import requests import requests
import yaml
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from mastodon import Mastodon from mastodon import Mastodon
@ -8,10 +9,18 @@ url = (
+ "/fragments?name=story_grid&source=homepage&view_id=1&page=1&per_page=12" + "/fragments?name=story_grid&source=homepage&view_id=1&page=1&per_page=12"
) )
log_file = "kuow_bot_logfile.txt" log_file = "kuow_bot_logfile.txt"
mastodon = Mastodon(access_token="kuow_bot_mastodon.secret") config = yaml.safe_load(open("config.yml"))
stadiamaps_api_key = config["stadiamaps"]["api_key"]
nominatim_url = config["nominatim"]["api_base_url"]
mastodon = Mastodon(
client_id=config["mastodon"]["client_id"],
client_secret=config["mastodon"]["client_secret"],
access_token=config["mastodon"]["access_token"],
api_base_url=config["mastodon"]["api_base_url"],
)
r = requests.get(url) kuow_response = requests.get(url)
soup = BeautifulSoup(r.content, "html.parser") soup = BeautifulSoup(kuow_response.content, "html.parser")
articles = soup.find_all("span", class_="txt") articles = soup.find_all("span", class_="txt")
# Reverse articles, so that if multiple new ones have been found, they'll be posted in order of when published # Reverse articles, so that if multiple new ones have been found, they'll be posted in order of when published
articles.reverse() articles.reverse()