pull/5/head
Lasse Edfast 5 years ago
parent d4bba7fb08
commit 05ac36757b
  1. 3
      facebook/arangodb.py
  2. 2
      facebook/helpers.py
  3. 13
      facebook/scrapers.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:

@ -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:

@ -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()
Loading…
Cancel
Save