finished py script
This commit is contained in:
@@ -140,4 +140,39 @@ def generate_html(quakes, output_file="geonet_earthquakes.html", css_file="style
|
||||
</html>
|
||||
"""
|
||||
|
||||
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
f.write(html_content)
|
||||
print(f"Generated {output_file} with {len(quakes)} earthquakes.)
|
||||
|
||||
if __name__ == "__main__":
|
||||
output_html_file = "geonet_earthquakes_list.html"
|
||||
css_file_name = "style.css"
|
||||
min_mmi_threshold = 8
|
||||
earthquake_limit = 20
|
||||
filter_today_only = True
|
||||
update_interval_minutes = 1
|
||||
|
||||
print(f"Starting Geonet Earthquake Display Generator. HTML file: `{output_html_file}`")
|
||||
print(f"Updating every {update_interval_minutes} minute(s).")
|
||||
print(f"Filtering for MMI {min_mmi_threshold}+, max {earthquake_limit} from today (NZT), including deleted events from today.")
|
||||
|
||||
latest_quakes = get_earthquakes(
|
||||
min_mmi=min_mmi_threshold,
|
||||
limmit=earthquake_limit,
|
||||
from_today_only=filter_today_only
|
||||
)
|
||||
generate_html(latest_quakes, output_html_file, css_file_name)
|
||||
|
||||
# continuous updater loop untl ctrl+C
|
||||
import time
|
||||
while True:
|
||||
try:
|
||||
latest_quakes = get_earthquakes(
|
||||
min_mmi=min_mmi_threshold,
|
||||
limit=earthquake_limit,
|
||||
from_today_only=filter_today_only
|
||||
)
|
||||
generate_html(latest_quakes, output_html_file, css_file_name)
|
||||
except Exception as e:
|
||||
print(f"An error occurred during update: {e}")
|
||||
time.sleep(update_interval_minutes * 60)
|
||||
|
Reference in New Issue
Block a user