#!/usr/bin/python3
import os
import urllib.request as request
file_path = os.path.dirname(os.path.realpath(__file__))
config_file = file_path + "/input.txt"
config_file = open(config_file)
def setup_header_html():
html = ""
return html
def download(url):
#print( f"site name: {url}")
fp = request.urlopen(url)
raw_site = fp.read()
raw_site = raw_site.decode("utf8")
fp.close()
return(raw_site)
def pull_banner(site_name):
raw_site = download(site_name)
start_of_image = "background-image: url("
end_of_image = ')">'
url = raw_site.split(start_of_image)[-1]
url = url.split(end_of_image)[0]
html = f""""""
return(html)
def get_title(site_url):
#download site raw HTML
#TODO only call this once per site
raw_site = download(site_url)
start_of_title = "
" tag blog_text = ">".join(blog_text.split(">")[1:]) #for line in raw_site.split('\n'): return(blog_text) email_title = "" HTML = setup_header_html() site_index = 0 div_classes = ["grey-wrapper","main-wrapper"] for config_line in config_file.readlines(): if config_line.startswith("#"): continue if config_line.startswith("title:"): email_title = config_line.split(":")[-1] if config_line.startswith("banner_site:") or config_line.startswith("site:"): site_index += 1 div_class = div_classes[site_index % len(div_classes)] site_url = config_line.split("site:")[-1] site_title = get_title(site_url) if config_line.startswith("banner_site:"): banner_html = pull_banner(site_url) else: banner_html = "" if div_class != "main-wrapper": div = f"""