Skip to content

Commit

Permalink
refactor datr cookie add (#915)
Browse files Browse the repository at this point in the history
Revised the insertion of the datr cookie in a cleaner and more
appropriate way.
  • Loading branch information
Ianneee authored Oct 16, 2022
1 parent e8387e9 commit 4199a6a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions facebook_scraper/facebook_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,10 @@ def submit_form(self, response, extra_data={}):
def login(self, email: str, password: str):
response = self.get(self.base_url)

cookies_values = re.findall(r'js_datr","([^"]+)', response.html.html)
if len(cookies_values) == 1:
self.session.cookies.set("datr", cookies_values[0])
datr_cookie = re.search('(?<=_js_datr",")[^"]+', response.html.html)
if datr_cookie:
cookie_value = datr_cookie.group()
self.session.cookies.set('datr', cookie_value)

response = self.submit_form(
response, {"email": email, "pass": password, "_fb_noscript": None}
Expand Down

0 comments on commit 4199a6a

Please sign in to comment.