Skip to content

Instantly share code, notes, and snippets.

@phoenixthrush
Last active August 13, 2025 02:01
Show Gist options
  • Select an option

  • Save phoenixthrush/0fefbdc937f513161e50c5dfca54cc9a to your computer and use it in GitHub Desktop.

Select an option

Save phoenixthrush/0fefbdc937f513161e50c5dfca54cc9a to your computer and use it in GitHub Desktop.
Extract instagram.com cookies.txt #Cookies #Instagram #Python
import browser_cookie3
import time
# Get cookies from Brave for Instagram
cookies = browser_cookie3.brave(domain_name='instagram.com')
# Save to cookies.txt in Netscape format
with open("cookies.txt", "w") as f:
f.write("# Netscape HTTP Cookie File\n")
f.write("# This file was generated by browser-cookie3\n\n")
for c in cookies:
# Skip expired cookies
if c.expires and c.expires < time.time():
continue
domain = c.domain
include_subdomain = "TRUE" if domain.startswith(".") else "FALSE"
path = c.path
secure = "TRUE" if c.secure else "FALSE"
expires = str(int(c.expires)) if c.expires else "0"
name = c.name
value = c.value
line = f"{domain}\t{include_subdomain}\t{path}\t{secure}\t{expires}\t{name}\t{value}\n"
f.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment