I am trying to write cookies to a json file.
cookies = web.get_cookies()
with open('test.json', 'w') as outputdata:
json.dump(cookies, outputdata)
sleep(5)
Which writes cookies to test.json.
I am trying to create a cookie file for each user and each website visited such as.
cookies/{user}/{website}.json
'w' should create a file if it does not exist. But instead of the file being created I am getting error file does not exist.
I have defined the variables, printing user shows the username.
When manually creating the file such as test.json in the first example the script works.
How can I create the file at the path with variables?
Thank you