Guest User

Untitled

a guest
Oct 15th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. from datetime import datetime
  2. def convert_cookies(cookie_file):
  3. buffer = ['# Netscape HTTP Cookie File', '']
  4. with open(cookie_file, 'r') as f:
  5. for line in f:
  6. name, value, domain, path, expires, _, _, secure, _, _ = line.strip().split("\t")
  7. expires_dt = int(datetime.fromisoformat(expires.rstrip('Z')).timestamp()) if expires != 'Session' else ''
  8. if secure:
  9. secure = 'TRUE'
  10.  
  11. buffer.append('\t'.join([domain, 'TRUE', path, secure, str(expires_dt), name, value]))
  12.  
  13. with open(cookie_file, 'w') as f:
  14. f.write("\n".join(buffer))
Add Comment
Please, Sign In to add comment