Changes how to handle pictures with very many likes (etc)

pull/5/head
Lasse Edfast 5 years ago
parent 086e38a0c2
commit eeac187e15
  1. 1
      .gitignore
  2. 8
      facebook/__main__.py
  3. BIN
      facebook/__pycache__/helpers.cpython-37.pyc
  4. BIN
      facebook/__pycache__/scrapers.cpython-37.pyc
  5. 2
      facebook/helpers.py
  6. 7
      facebook/scrapers.py

1
.gitignore vendored

@ -6,3 +6,4 @@
*.pkl
/facebook/test.py
/data/*
*.html

@ -92,7 +92,13 @@ if __name__ == "__main__":
members_checked = arangodb.checked_members()
if user.username not in members_checked:# Hämta reaktioner för den första användaren LÄGG TILL NOT IN MEMBERS_CHECKED
profile_picture_reactions(profile, user, all_pictures, first=True, single=single)
try:
profile_picture_reactions(profile, user, all_pictures, first=True, single=single)
except:
print(traceback.format_exc())
if len(users) == 1:
for profile in profiles:
profile.unused()
friends = arangodb.friends_of_user(user.username)
friends_unchecked = list(set(friends) - set(members_checked))
# Här följer cookien med så att vi fortfarnade är inloggade

@ -22,7 +22,7 @@ def sleep_(t):
def update_cookie(cookies, profile_name):
""" Uppdaterar cookie för browser """
with open("./data/cookie_{}.pkl".format(profile_name), "wb") as f:
with open("../data/cookie_{}.pkl".format(profile_name), "wb") as f:
pickle.dump(cookies, f)

@ -194,8 +194,10 @@ def profile_picture_reactions(profile, user, all_pictures, first=False, single =
picture.no_reactions = re.search(r"total_count=(\d+)", url_limit).group(1)
limit = re.search(r"limit=(\d+)", url_limit).group(1)
except UnboundLocalError:
limit = 999
except UnboundLocalError: #fel9
write_error(9, soup=profile.viewing(), traceback=traceback.format_exc())
# Bilder med väldigt många likes går inte att visa så här?
continue
# Addera bilden till arrango
picture.add_to_db()
@ -209,6 +211,7 @@ def profile_picture_reactions(profile, user, all_pictures, first=False, single =
profile.browser.open(url_limit)
update_cookie(profile.browser.session.cookies, profile.name)
# Gå igenom alla som reagerat och för in i arango
for li in profile.viewing().find_all("li"):
friend = Friend(user.username)

Loading…
Cancel
Save