Skip to content

Commit

Permalink
Fix for missing reactors
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-ninja committed Mar 31, 2022
1 parent 6ed8a1e commit c41e14e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions facebook_scraper/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,10 @@ def extract_reactors(self, response, reaction_lookup):
if not reaction_type:
logger.error(f"Don't know {emoji_class}")
except AttributeError:
reaction_type = emoji_style_lookup[
elem.find(f"div>i", first=True).attrs.get("style")
]
emoji_style = elem.find(f"div>i[style]", first=True).attrs.get("style")
reaction_type = emoji_style_lookup.get(emoji_style)
if not reaction_type:
logger.error(f"Don't know {emoji_style}")
yield {
"name": elem.find("strong", first=True).text,
"link": utils.urljoin(FB_BASE_URL, elem.find("a", first=True).attrs.get("href")),
Expand Down
2 changes: 2 additions & 0 deletions facebook_scraper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from requests.cookies import RequestsCookieJar
from requests_html import DEFAULT_URL, Element, PyQuery
import json
import traceback

from . import exceptions
import logging
Expand Down Expand Up @@ -271,6 +272,7 @@ def safe_consume(generator, sleep=0):
result.append(item)
time.sleep(sleep)
except Exception as e:
traceback.print_exc()
logger.error(f"Exception when consuming {generator}: {type(e)}: {str(e)}")
return result

Expand Down

0 comments on commit c41e14e

Please sign in to comment.