From adc73a2275c7f471c3bd91c8088ea0ab1851b4ec Mon Sep 17 00:00:00 2001 From: Lasse Date: Fri, 19 Mar 2021 16:08:39 +0100 Subject: [PATCH] Changed in globals() to in locals --- facebook/scrapers.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/facebook/scrapers.py b/facebook/scrapers.py index 4799df9..20fcc94 100644 --- a/facebook/scrapers.py +++ b/facebook/scrapers.py @@ -83,7 +83,8 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod user.add_to_db() # Gå till profilbilden (den första som kommer upp när man går till profilen) - if not hasattr(user, "url_album"): + + if not hasattr(user, "url_album"): # Om profilen inte har profilalbum write_error(9, soup=profile.viewing(), user=user.username) if user.url_other_picture != '': # Använd eventuell extrabild och ta bort den från användaren @@ -100,7 +101,7 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod return None # ATT GÖRA Här kan andra bilder väljas istället - else: + else: # Normalfallet där användaren har profilbildsalbum profile.browser.open(user.url_album) # Samla alla profilbilder i en lista @@ -129,7 +130,7 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod url_pics = url_pics[:1] elif mode == 'few' and len(url_pics) > 1: url_pics = url_pics[:1] + url_pics[-1:] - + # Gå igenom valda bilder. for pic in url_pics: # Skriv ut vilken bild som behandlas. @@ -142,8 +143,8 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod picture.id = str(re.search('\d+', picture.id).group()) except: pass - if picture.id in all_pictures: - continue + # if picture.id in all_pictures: + # continue sleep_(5) try: @@ -184,11 +185,11 @@ def profile_picture_reactions(profile, user, all_pictures, first_user=False, mod picture.url_full = pic[ : pic.find("&") ] # Den fullständiga adressen till bilden, används som _key i pictures - if 'url_reactions' not in globals(): + if 'url_reactions' not in locals(): for a in profile.viewing().find_all("a", href=True): if '/likes/' in a["href"]: url_reactions = url_bas + str(a["href"]) - if 'url_reactions' not in globals(): + if 'url_reactions' not in locals(): for div in profile.viewing().find_all("div", href=True): if 'like this' in div.text: url_reactions = url_bas + str(div["href"])