Add way to change hour interval

This commit is contained in:
Isaac Shoebottom 2023-01-24 15:17:49 -04:00
parent 2c262ae16c
commit 83cb2f5c74

View File

@ -1,6 +1,7 @@
import time import time
import urllib.request import urllib.request
import urllib.error import urllib.error
import sys
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
@ -27,12 +28,24 @@ def scrape():
if __name__ == '__main__': if __name__ == '__main__':
hours = 3
arg_count = len(sys.argv)
if arg_count == 1: # No arguments
print("No arguments given, using default value of 3 hours")
else:
try:
hours = int(sys.argv[1]) # First argument is the script name, second is the first argument
print("Using argument value of " + str(hours) + " hours")
except ValueError:
print("Invalid argument given, using default value of 3 hours")
# start = time.time() # start = time.time()
# 60 seconds * 60 minutes * 3 hours # 60 seconds * 60 minutes * 3 hours
timer = 60 * 60 * 3 timer = 60 * 60 * hours
text = scrape() text = scrape()
print("Started checking for new jobs, will check every 3 hours.") print("Started checking for new jobs")
while True: while True:
try: try: