New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cookies-converter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookies-converter

Cookies converter

1.0.1
PyPI
Maintainers
1

CookiesConverter

Version: v1.0.0

Install

pip install cookies-converter

Examples usage

Formats

from cookies_converter import CookiesConverter


def read_file(file: str) -> str:
    with open(file, 'r', encoding='utf-8') as _open_file:
        cookies_content = _open_file.read()
    return cookies_content


def print_formats_cookies(converter: CookiesConverter, domain: str) -> None:
    print("Netscape cookies: ", converter.to_netscape(domain))
    print("Json cookies: ", converter.to_json(domain))
    print("Key value cookies: ", converter.to_key_value(domain))


def main() -> None:
    converter = CookiesConverter()
    domain = "netflix.com"

    converter.from_netscape(read_file("netscape_cookies.txt"))
    print_formats_cookies(converter, domain)
    converter.clear_cookies()
    print("----------------------------")

    converter.from_json(read_file("json_cookies.json"))
    print_formats_cookies(converter, domain)


if __name__ == '__main__':
    main()


Request

import requests

from cookies_converter import CookiesConverter


def main() -> None:
    converter = CookiesConverter()
    converter.from_netscape(open('netscape_cookies.txt', 'r', encoding="utf-8").read())

    response = requests.get('https://www.netflix.com/', cookies=converter.to_key_value("netflix.com"))
    print(response.status_code)


if __name__ == '__main__':
    main()


FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts