|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import requests
|
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
from time import time
|
|
|
|
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
|
|
|
|
|
|
|
|
def scrape():
|
|
|
|
@ -25,12 +26,14 @@ def scrape():
|
|
|
|
|
time = timespan.split(' ')[0]
|
|
|
|
|
|
|
|
|
|
output += time
|
|
|
|
|
output += ' Uhr'
|
|
|
|
|
if time != 'Ganztags':
|
|
|
|
|
output += ' Uhr'
|
|
|
|
|
output += ', '
|
|
|
|
|
|
|
|
|
|
# place
|
|
|
|
|
output += data[2].text.strip()
|
|
|
|
|
output += ', '
|
|
|
|
|
if len(data) > 2:
|
|
|
|
|
output += data[2].text.strip()
|
|
|
|
|
output += ', '
|
|
|
|
|
|
|
|
|
|
# title
|
|
|
|
|
output += '<b>'
|
|
|
|
@ -48,20 +51,27 @@ def scrape():
|
|
|
|
|
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
|
|
|
|
def do_GET(self):
|
|
|
|
|
current_time = time()
|
|
|
|
|
if cache['time'] < current_time - 30:
|
|
|
|
|
html = templateHtml.replace('--body--', scrape())
|
|
|
|
|
cache['output'] = html.encode('utf-8')
|
|
|
|
|
cache['time'] = current_time
|
|
|
|
|
|
|
|
|
|
self.send_response(200)
|
|
|
|
|
self.end_headers()
|
|
|
|
|
html = templateHtml.replace('--body--', scrape())
|
|
|
|
|
self.wfile.write(html.encode('utf-8'))
|
|
|
|
|
self.wfile.write(cache['output'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open('template.html', 'r') as templateFile:
|
|
|
|
|
templateHtml = templateFile.read()
|
|
|
|
|
|
|
|
|
|
cache = {
|
|
|
|
|
"time": 0,
|
|
|
|
|
"output": None
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
httpd = HTTPServer(('', 8000), SimpleHTTPRequestHandler)
|
|
|
|
|
httpd.serve_forever()
|
|
|
|
|