thewh1teagle / rookie

Load cookies from your web browsers
https://crates.io/crates/rookie
MIT License
204 stars 18 forks source link

Some cookies are missing(?) #5

Closed 5j9 closed 1 year ago

5j9 commented 1 year ago
import browser_cookie3, rookiepy

print(f'{len(rookiepy.firefox())=}')
print(f'{len(browser_cookie3.firefox())=}')

print(len(rookiepy.firefox(['google.com'])))
print(len(browser_cookie3.firefox(domain_name='google.com')))

On my Windows 10 system the above scripts prints:

len(rookiepy.firefox())=675
len(browser_cookie3.firefox())=7104
47
51

Not sure if my method of comparison above is correct, but it looks to me that browser_cookie3 is able to find more cookies.

thewh1teagle commented 1 year ago

@5j9 You right, some cookies from current session are missing. but from what you sent something is strange,

len(rookiepy.firefox())=675
len(browser_cookie3.firefox())=7104

what's the numbers 675 and 7104?

stappersg commented 1 year ago

Not sure if my method of comparison above is correct

Me neither.

Idea: Print the cookies names. With rookie and for comparison with browser_cookie3.

5j9 commented 1 year ago

Idea: Print the cookies names. With rookie and for comparison with browser_cookie3.

Here is another example with names printed:

import browser_cookie3, rookiepy

print('rookiepy:')
for c in rookiepy.firefox(['github.com']):
    print(c.name)

print('\n\nbrowser_cookie3:')
for c in browser_cookie3.firefox(domain_name='github.com'):
    print(c.name)

Prints:

rookiepy:
_octo
logged_in
_device_id
dotcom_user
fileTreeExpanded
_docs-events
user_session
__Host-user_session_same_site
has_recent_activity

browser_cookie3:
_octo
logged_in
dotcom_user
fileTreeExpanded
color_mode
preferred_color_mode
tz
_device_id
user_session
__Host-user_session_same_site
has_recent_activity
_gh_sess
ignored_unsupported_browser_notice
tz
_docs-events
_csrf
LiSESSIONID
_gh_sess
_helphub_session
state
logged
token
_support_session

what's the numbers 675 and 7104?

They are the result of python f-string evaluation.

print(f'{1+1=}')
# prints:
# 1+1=2
thewh1teagle commented 1 year ago

@5j9 Oh I see, but I'm still not sure how many cookies you have from each function

len(rookiepy.firefox())=675 <- this is the len?
len(browser_cookie3.firefox())=7104 <- this is the len?
47 <- what's that?
51 <- what's that?
5j9 commented 1 year ago

Sorry for the messy example. I should've used the same syntax for all print statements. Basically

thewh1teagle commented 1 year ago

Thanks. I'm working on adding session cookies to rookie in firefox as well. in the meanwhile, if it's possible for you to check again the length with little modification in browser_cookie3 it would be great.

  1. Navigate to the browser_cookie3 folder (just click some function in your ide it should go there)
  2. and then change here:

browser_cookie3/__init__.py LINE 980 browser_cookie3/__init__.py LINE 981 just comment out both in your library which you installed on your PC, and check again the lengths to see if it's the same as from rookiepy

5j9 commented 1 year ago

comment out both in your library which you installed on your PC, and check again the lengths to see if it's the same as from rookiepy

After the change the difference is almost gone (actually rookiepy is showing a few more cookies this time):

thewh1teagle commented 1 year ago

Thanks for checking, that means it probably the reason, I published new version which takes session cookies as well :) You can update it with pip install -U rookiepy

5j9 commented 1 year ago

Great!

With version 0.2.5 installed:

Note that now specifying domains seems to have lost its filtering effect and rookiepy.firefox(['google.com']) returns an unusually high number of cookies.

5j9 commented 1 year ago

rookiepy.firefox(['google.com']) returns an unusually high number of cookies.

Resolved in v0.2.6. Perfect! Thank you!