Bot for fetching the schema.org
full hierarchy to generate the Hierarchy.pickle file
The Bot class will check for the existence of the pickle file and for the version
After updating the Hierarchy.pickle file, a new static index.html will be generated
The Bot should be called via a cron job every 24 hours
To restart the server(s), the restart(port) function should be called for each port as shown below If the ports are consecutive, a for-loop can be used, of course.
This code is, naturally, inside the schema_bot.py file
if __name__ == "__main__":
from os import chdir
print('Schema Bot - main')
# Change the base dir to where this __file__ is located
# Same location as the Hierarchy.pickle file
FILE_NAME = 'schema_bot.py'
if __file__ != FILE_NAME:
BASE_DIR = __file__[:__file__.index(FILE_NAME)]
chdir(BASE_DIR)
# Start the Bot
# Check if file exists
# Check if version is correct
b = Bot()
# Everything happens while the bot is alive
while b.is_alive():
pass
# Restart the server(s) if the pickle file has been updated
if b.updated:
restart(8000) # Restart server at port 8000
restart(8001) # Etc
print('Schema Bot - main finished')