DeaD_EyE icon

decode amazon links

DeaD_EyE | PRO | 04/13/22 01:26:55 PM UTC | 0 ⭐ | 609 👁️ | Never ⏰ | []
Python |

470 B

|

None

|

0 👍

/

0 👎

from base64 import b64decode
from urllib.parse import urlparse, unquote
 
 
def parse_query(query):
    return dict(item.split("=", maxsplit=1) for item in unquote(query).split("&"))
 
 
def query(url):
    query = urlparse(url).query
    result = parse_query(query)
    # if spLa exists, it's a base64 encoded string
    # decoding it and creating a sub-dict of it
    if "spLa" in result:
        result["spLa"] = parse_query(b64decode(result["spLa"]))
 
    return result

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎