Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nodriver]How to get HttpOnly cookies #1954

Open
TonyLiooo opened this issue Jul 19, 2024 · 2 comments
Open

[nodriver]How to get HttpOnly cookies #1954

TonyLiooo opened this issue Jul 19, 2024 · 2 comments

Comments

@TonyLiooo
Copy link

All the cookies on the website are HttpOnly. Using await tab.send(cdp.storage.get_cookies()) causes it to hang indefinitely.

@TonyLiooo
Copy link
Author

@ultrafunkamsterdam I found the problem. It was because 'partitionKey' was just the URL, which caused 'get_cookies' to hang. The improvement can be done as follows:

class CookiePartitionKey:
    @classmethod
    def from_json(cls, json_input) -> CookiePartitionKey:
        if isinstance(json_input, str):
            return cls(
                top_level_site=json_input,
                has_cross_site_ancestor=False
            )
        elif isinstance(json_input, dict):
            return cls(
                top_level_site=str(json_input["topLevelSite"]),
                has_cross_site_ancestor=bool(json_input["hasCrossSiteAncestor"])
            )

@ThePhaseless
Copy link

OMG You are a savior! I was struggling for 4 days trying to fix it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants