Removed message counter as it doesn't appear to work anyway...

This commit is contained in:
Klaus-Uwe Mitterer 2017-01-31 12:34:19 +01:00
parent 242db43905
commit 5a6a05cab9

View file

@ -86,7 +86,7 @@ def messageHandler(sender, recipient, mid, date, driver, mode = 0, db = dbtools.
except: except:
pass pass
def pageHandler(driver, db = dbtools.dbHelper(), ret = {"rec": 0,"snt": 0}): def pageHandler(driver, db = dbtools.dbHelper()):
mode = 0 mode = 0
abort = True abort = True
juha = BeautifulSoup(driver.page_source, "html5lib") juha = BeautifulSoup(driver.page_source, "html5lib")
@ -105,10 +105,8 @@ def pageHandler(driver, db = dbtools.dbHelper(), ret = {"rec": 0,"snt": 0}):
abort = False abort = False
if mode == 0: if mode == 0:
messageHandler(user, setuptools.user(), mid, date, driver, mode, db) messageHandler(user, setuptools.user(), mid, date, driver, mode, db)
ret["rec"] += 1
else: else:
messageHandler(setuptools.user(), user, mid, date, driver, mode, db) messageHandler(setuptools.user(), user, mid, date, driver, mode, db)
ret["snt"] += 1
except IndexError: except IndexError:
pass pass
except IndexError: except IndexError:
@ -119,26 +117,25 @@ def pageHandler(driver, db = dbtools.dbHelper(), ret = {"rec": 0,"snt": 0}):
else: else:
return True 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: if mode == 0:
loadPage("https://www.planetromeo.com/mitglieder/messages/uebersicht.php?view=all&seite=" + str(p), driver) loadPage("https://www.planetromeo.com/mitglieder/messages/uebersicht.php?view=all&seite=" + str(p), driver)
else: else:
loadPage("https://www.planetromeo.com/mitglieder/messages/uebersicht.php?view=sent&seite=" + str(p), driver) loadPage("https://www.planetromeo.com/mitglieder/messages/uebersicht.php?view=sent&seite=" + str(p), driver)
if pageHandler(driver, db, ret): if pageHandler(driver, db):
siteHandler(driver, mode, ret, p+1, db) siteHandler(driver, mode, p+1, db)
def mainHandler(ret = {"rec": 0,"snt": 0}): def mainHandler():
siteHandler(driver, 0, ret, db=db) siteHandler(driver, 0, db=db)
siteHandler(driver, 1, ret, db=db) siteHandler(driver, 1, db=db)
if __name__ == "__main__": if __name__ == "__main__":
db = dbtools.dbHelper() db = dbtools.dbHelper()
driver = webdriver.Firefox() driver = webdriver.Firefox()
ret = {"rec": 0,"snt": 0}
try: try:
if loginHandler(driver): if loginHandler(driver):
p = multiprocessing.Process(target=mainHandler, args=([ret])) p = multiprocessing.Process(target=mainHandler)
p.start() p.start()
p.join(1500) p.join(1500)
if p.is_alive(): if p.is_alive():
@ -146,5 +143,3 @@ if __name__ == "__main__":
p.join() p.join()
finally: finally:
driver.close() driver.close()
print("Received", ret["rec"], "messages")
print("Sent", ret["snt"], "messages")