mirror of
https://github.com/simon987/hexlib.git
synced 2025-04-10 14:06:43 +00:00
add cookie stuff
This commit is contained in:
parent
3e477c9f98
commit
e5b5fa9c25
35
hexlib/web.py
Normal file
35
hexlib/web.py
Normal file
@ -0,0 +1,35 @@
|
||||
from http.cookiejar import Cookie
|
||||
|
||||
from dateutil.parser import parse
|
||||
|
||||
|
||||
def cookie_from_string(text: str, domain: str) -> Cookie:
|
||||
|
||||
tokens = [t.strip() for t in text.split(";")]
|
||||
|
||||
name, value = tokens[0].split("=")
|
||||
|
||||
path = None
|
||||
expires = None
|
||||
|
||||
for tok in tokens[1:]:
|
||||
name, value = tok.split("=")
|
||||
if name == "path":
|
||||
path = value
|
||||
if name == "expires":
|
||||
expires = parse(value).timestamp()
|
||||
|
||||
return Cookie(
|
||||
version=None,
|
||||
name=name, value=value,
|
||||
port=None, port_specified=False,
|
||||
domain=domain, domain_specified=True, domain_initial_dot=False,
|
||||
path=path, path_specified=path is not None,
|
||||
secure=False,
|
||||
expires=expires,
|
||||
discard=None,
|
||||
comment=None,
|
||||
comment_url=None,
|
||||
rest=None,
|
||||
rfc2109=False
|
||||
)
|
@ -1,3 +0,0 @@
|
||||
ImageHash
|
||||
influxdb
|
||||
siphash
|
4
setup.py
4
setup.py
@ -2,12 +2,12 @@ from setuptools import setup
|
||||
|
||||
setup(
|
||||
name="hexlib",
|
||||
version="1.1",
|
||||
version="1.2",
|
||||
description="Misc utility methods",
|
||||
author="simon987",
|
||||
author_email="me@simon987.net",
|
||||
packages=["hexlib"],
|
||||
install_requires=[
|
||||
"ImageHash", "influxdb", "siphash"
|
||||
"ImageHash", "influxdb", "siphash", "python-dateutil"
|
||||
]
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user