Skip to content

Commit

Permalink
Relax regex parsing of csrf_token
Browse files Browse the repository at this point in the history
No longer works because instagram changed schema.

The relevant JSON now looks something like this:
["InstagramSecurityConfig",[],{"csrf_token":"abcdefg"},1234]
  • Loading branch information
Techcable authored and Tatsh committed Mar 5, 2025
1 parent 89bf729 commit 5ab1834
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions instagram_archiver/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def _setup_session(self,
if 'instagram.com' in cookie.domain))
})
r = self._get_rate_limited('https://www.instagram.com', return_json=False)
m = re.search(r'"config":{"csrf_token":"([^"]+)"', r.text)
assert m is not None
self._session.headers.update({'x-csrftoken': m.group(1)})
m = list(re.finditer(r'{"csrf_token":"([^"]+)"', r.text))
assert len(m) == 1, m
self._session.headers.update({'x-csrftoken': m[0].group(1)})

def _save_to_log(self, url: str) -> None:
if self._no_log:
Expand Down

0 comments on commit 5ab1834

Please sign in to comment.