开发者

Python CookieJar - Cookies Set By Google Analytics

开发者 https://www.devze.com 2023-02-09 23:46 出处:网络
I\'m a little bit confused about this situation. I\'m working on a script to login into a website. I\'m using CookieJar and the login method is working just fine.

I'm a little bit confused about this situation. I'm working on a script to login into a website. I'm using CookieJar and the login method is working just fine.

If I try to display the cookieJar content:

for index, coo开发者_JS百科kie in enumerate(cw.cj):
        print index, ':', cookie

I get a cookie as:

0   :   <Cookie C4CSESSID=tqb2qn92du8i9k5r4vnpd83i73 for www.example.com/>

But in my Firefox if I'm looking for that domain (in fact, w/out www) in the cookies editor, I can see also the google analytics ones (__utma, __utmc, etc).

How can I capture this cookies also in cj? My goal is to be able to modify __utmb cookie content. (I can do it from FF but I want from the script also)

Thanks


I think you get that cookie once the tracking code on that page has executed (in the response from the Google server). As it's javascript, you'll need to find a way to either interpret Javascript in your code, or mimic the request the tracking code issues.

Interpreting Javascript out of the context of a browser could prove tricky, I suspect that the tracking code needs access to the DOM, which it probably doesn't have if you get the page with urllib for example.


These cookies are set by the javascript code for Google Analytics. You need to interpret this code to get the cookie.

Hard work


I'm wondering, if creating a cookieJar and adding some "mangled" cookies there (__utmb for example) it makes a difference in the next queries on that website?

Something as an overwriting for the ga cookie.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号