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:
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")