Commits

Stephen Tanner  committed f2ffb4b

Fixed running loop

  • Participants
  • Parent commits 6361a44

Comments (0)

Files changed (2)

File config.json.example

             "link_class": "class_of_link",
             "domain": "http://somesite.com",
             "post_class": "class_of_post"
-            }
+        }
+        "reddit": {
+            "domain": "http://www.reddit.com",
+            "path": "/r/Shave_Bazaar/new/",
+            "link_class": "title",
+            "post_class": "expando"
+        },
         },
     "includes": ["term1", "term2", "terma", "termb", "termc"],
     "excludes": ["termx", "termy", "termz"],
 import json
 import asyncio
 from webmaster import WebMaster
+import time
 
 #setup argument parsing
 parser = argparse.ArgumentParser(description='Get notifications when search terms appear on certain forums.')
         text = cf.read()
         config = json.loads(text)
 
+    loop = asyncio.get_event_loop()
     webmaster = WebMaster(config["includes"], config["excludes"], config["database"], config['email'])
-    loop = asyncio.get_event_loop()
-    loop.run_until_complete(webmaster.start_fetch(config["sites"]))
+    while True:
+        # try:
 
+        loop.run_until_complete(webmaster.start_fetch(config["sites"]))
+        # except Exception as inst:
+            # print(inst)
+        # finally:
+        print("Sleeping: " + str(config['sleep']/60) + " minutes")
+        time.sleep(config["sleep"])
+        #close the event loop
+        
 
+    loop.close()
 
-    #close the event loop
-    loop.close()
 
 if __name__ == "__main__":
     # execute only if run as a script