You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
508 B
20 lines
508 B
3 years ago
|
from bs4 import BeautifulSoup
|
||
|
import os
|
||
|
|
||
|
fortune = os.popen("/usr/games/fortune | /usr/games/cowsay").read()
|
||
|
|
||
|
file_name = "/var/www/html/index.html"
|
||
|
soup = None
|
||
|
|
||
|
print("The emergency fortune system has set the fortune to {}".format(fortune))
|
||
|
|
||
|
with open(file_name, "r") as the_file:
|
||
|
soup = BeautifulSoup(the_file, features="html.parser")
|
||
|
|
||
|
fortune_holder = soup.find(id="fortune-container")
|
||
|
|
||
|
fortune_holder.string = fortune
|
||
|
|
||
|
with open(file_name, "w") as the_file:
|
||
|
the_file.write(str(soup))
|