From 9c53eab12fb7f919bce889228356723c60778d8e Mon Sep 17 00:00:00 2001 From: lub Date: Fri, 1 May 2020 18:01:59 +0200 Subject: [PATCH] add intial config --- scrape.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scrape.py b/scrape.py index 277e7cd..25973e0 100644 --- a/scrape.py +++ b/scrape.py @@ -1,7 +1,17 @@ +from os import environ + import requests import re from bs4 import BeautifulSoup + + +def get_accesstoken_from_file(accesstoken_path): + accesstoken_file = open(accesstoken_path, 'r') + single_accesstoken = accesstoken_file.read().strip() + accesstoken_file.close() + + return single_accesstoken def get_blog(): url = 'https://news.blizzard.com/en-us/' html = requests.get(url).text @@ -60,6 +70,17 @@ def get_formatted_body(post): '

'+post['description']+'

' ) + +homeserver = environ['HOMESERVER_URL'] +mxid = environ['MXID_PREFIX'] +admin_room = environ['ADMIN_ROOM'] + +accesstoken = {} +for key in environ: + if (game := re.match('^ACCESSTOKEN_([A-Z]*)_FILE$', key)) is not None: + accesstoken[game[1].lower()] = get_accesstoken_from_file(environ[key]) + + blog = get_blog() for post in blog: print(get_body(post))