将Python输出导入HTML文件

时间:2019-04-14 16:41:57

标签: python html django

我已经在我的Django网站上进行了一段时间的尝试,但遇到了一个似乎无法解决的问题。所以一方面我有以下代码:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("--headless") 
options.add_argument('--no-sandbox') 
options.add_argument('start-maximized')
options.add_argument('disable-infobars')
options.add_argument("--disable-extensions")

url = 'https://old.reddit.com/r/Lain/new/'
driver = webdriver.Chrome(chrome_options=options)
driver.get(url)
sub = WebDriverWait(driver,10).until(EC.presence_of_all_elements_located((By.CLASS_NAME, "subscribers")))
onl = WebDriverWait(driver,10).until(EC.presence_of_all_elements_located((By.CLASS_NAME, "users-online")))


def onlineCheck():
    for s,o in zip(sub,onl):
        status = (s.text + ' susbscribed, ' + o.text + ' currently viewing')
        return status

    driver.quit()

另一方面,一个空的HTML文件。我要做的是将onlineCheck函数的输出打印到HTML文件。

0 个答案:

没有答案