From 5a6a05cab96f93697547c0b139417759910a56cf Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Tue, 31 Jan 2017 12:34:19 +0100 Subject: [PATCH] Removed message counter as it doesn't appear to work anyway... --- handler.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/handler.py b/handler.py index 58de016..27815fa 100755 --- a/handler.py +++ b/handler.py @@ -86,7 +86,7 @@ def messageHandler(sender, recipient, mid, date, driver, mode = 0, db = dbtools. except: pass -def pageHandler(driver, db = dbtools.dbHelper(), ret = {"rec": 0,"snt": 0}): +def pageHandler(driver, db = dbtools.dbHelper()): mode = 0 abort = True juha = BeautifulSoup(driver.page_source, "html5lib") @@ -105,10 +105,8 @@ def pageHandler(driver, db = dbtools.dbHelper(), ret = {"rec": 0,"snt": 0}): abort = False if mode == 0: messageHandler(user, setuptools.user(), mid, date, driver, mode, db) - ret["rec"] += 1 else: messageHandler(setuptools.user(), user, mid, date, driver, mode, db) - ret["snt"] += 1 except IndexError: pass except IndexError: @@ -119,26 +117,25 @@ def pageHandler(driver, db = dbtools.dbHelper(), ret = {"rec": 0,"snt": 0}): else: return True -def siteHandler(driver, mode = 0, ret = {"rec": 0,"snt": 0}, p = 0, db = dbtools.dbHelper()): +def siteHandler(driver, mode = 0, p = 0, db = dbtools.dbHelper()): if mode == 0: loadPage("https://www.planetromeo.com/mitglieder/messages/uebersicht.php?view=all&seite=" + str(p), driver) else: loadPage("https://www.planetromeo.com/mitglieder/messages/uebersicht.php?view=sent&seite=" + str(p), driver) - if pageHandler(driver, db, ret): - siteHandler(driver, mode, ret, p+1, db) + if pageHandler(driver, db): + siteHandler(driver, mode, p+1, db) -def mainHandler(ret = {"rec": 0,"snt": 0}): - siteHandler(driver, 0, ret, db=db) - siteHandler(driver, 1, ret, db=db) +def mainHandler(): + siteHandler(driver, 0, db=db) + siteHandler(driver, 1, db=db) if __name__ == "__main__": db = dbtools.dbHelper() driver = webdriver.Firefox() - ret = {"rec": 0,"snt": 0} try: if loginHandler(driver): - p = multiprocessing.Process(target=mainHandler, args=([ret])) + p = multiprocessing.Process(target=mainHandler) p.start() p.join(1500) if p.is_alive(): @@ -146,5 +143,3 @@ if __name__ == "__main__": p.join() finally: driver.close() - print("Received", ret["rec"], "messages") - print("Sent", ret["snt"], "messages")