ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.54k stars 1.14k forks source link

[nodriver]How to get HttpOnly cookies #1954

Open TonyLiooo opened 1 month ago

TonyLiooo commented 1 month ago

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

TonyLiooo commented 1 month ago

@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 commented 1 month ago

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