From 05ac36757b64733dc61c6de8914335e56f834773 Mon Sep 17 00:00:00 2001 From: Lasse Date: Thu, 18 Mar 2021 20:53:58 +0100 Subject: [PATCH] Added TODO --- facebook/arangodb.py | 3 ++- facebook/helpers.py | 2 +- facebook/scrapers.py | 13 +++---------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/facebook/arangodb.py b/facebook/arangodb.py index 59e72a2..1e6db3d 100644 --- a/facebook/arangodb.py +++ b/facebook/arangodb.py @@ -53,9 +53,10 @@ def remove_profile(profile): f'{profile} blockerad och borttagen {datetime.now().strftime("%Y%m%d_%H:%M:%S")}.' ) +# TODO #2 Funktion för backup av databasen -# Starta koppling till arangodb +# Starta koppling till arangodb # Avkryptera lösen till arango for i in range(0, 6, 1): if i == 5: diff --git a/facebook/helpers.py b/facebook/helpers.py index cbe1410..cd9f6b9 100644 --- a/facebook/helpers.py +++ b/facebook/helpers.py @@ -20,7 +20,7 @@ def sleep_(t): print() sleep(random.randrange(0, 10, 1) / 4) - +# TODO #1 spara cookies till db def update_cookie(cookies, profile_name): """ Uppdaterar cookie för browser """ with open("../data/cookie_{}.pkl".format(profile_name), "wb") as f: diff --git a/facebook/scrapers.py b/facebook/scrapers.py index d95abb4..4799df9 100644 --- a/facebook/scrapers.py +++ b/facebook/scrapers.py @@ -166,7 +166,7 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod picture.date = profile.viewing().find("abbr").text except Exception as e: # Fel8 write_error(8, e=e, soup=profile.viewing(), url=pic, url_name='picture url', user=user.name, traceback=traceback.format_exc()) - # TODO lägg till fler bilder som kan gås igenom. + # TODO #3 lägg till fler bilder som kan gås igenom om det är få profilbilder. # Hämta länkar för bilden att userända sen #print(profile.viewing().prettify()) @@ -192,7 +192,6 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod for div in profile.viewing().find_all("div", href=True): if 'like this' in div.text: url_reactions = url_bas + str(div["href"]) - # ISSUE Det är fortfarande inte alla bilder som får en url_reaction # Hämta reaktioner för bilden sleep_(3) @@ -228,9 +227,7 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod # Gå igenom alla som reagerat och för in i arango for li in profile.viewing().find_all("li"): - friend = Friend(user.username) - if single == True: - friend.single = True + friend = Friend(user.username, mode) if "See more" in li.text: continue try: @@ -250,8 +247,6 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod # Lägg till vännens profil till arrango friend.add_to_db() - # Lägg till reaktion till arrango - except AttributeError as e: # Fel1 write_error( 1, @@ -262,7 +257,7 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod ) pass - + # Lägg till reaktion till databasen db.collection("picture_reactions").insert_many( picture.reactions, silent=True, overwrite=True ) @@ -279,8 +274,6 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod ) pass - ## ATT GÖRA För att lägga till fler reaktioner om det är få reaktioner på profilbilderna (måste uppdateras) - user.checked() \ No newline at end of file