Skip to main content

Cookies converter

Project description

CookiesConverter

Version: v1.0.0

Install

pip install git+https://github.com/RedKlaus/cookies_converter.git

Example usage

Formats

from cookies_converter.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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cookies_converter-1.0.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

cookies_converter-1.0.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file cookies_converter-1.0.0.tar.gz.

File metadata

  • Download URL: cookies_converter-1.0.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for cookies_converter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a67f8e9a5baa6e6216e8075ba7375a5999b4f8b8fc829d6c79ee1a850a2f16b7
MD5 359aa6318133c50b32775a8aeb0d483a
BLAKE2b-256 9d79cb433f458cea015c2ad3aa7a7738587ac1e65142585791b276380e80377c

See more details on using hashes here.

File details

Details for the file cookies_converter-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cookies_converter-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94007c4861040babbc198fe271f207aa7a6bf3f2e2ec0bbe72561c95d9e266a5
MD5 ccf8fdd8866a2544f064c8d1054a3261
BLAKE2b-256 69a44eecab35637a5492e56ad1c245b2622b0bae7154916fadf5bcc662d56f75

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page