i try to get all cookies (include cookies that set by javascript) from a website using python. At the moment i try that with the requests module.
The http cookies are not the problem. I can catch them with:
response = requests.get("http://example.com")
http_cookies = response.cookies
The cookies that are set by javascript is a little bit tricky.
I search the content from all <script ..>...</script>
tags and the integrated javascripts sources <script ... src="...">
on the website with regex.
Now i have a large list with strings that contains all the javascript on the page. I believe that all cookies that set by javascript have the form document.cookie = "...";
. Is that right?
I think that i can search in my list with the javascript code for substrings like document.cookie = "...";
with regex.
I'm correct? I am only interested in the cookie name. For example _ga
for Google Analytics.
Thanks for your help!