Skip to content

Instantly share code, notes, and snippets.

@adamghill
Created November 13, 2019 02:40
Show Gist options
  • Save adamghill/fd8e4693be989c4245d9b83a8ac1c136 to your computer and use it in GitHub Desktop.
Save adamghill/fd8e4693be989c4245d9b83a8ac1c136 to your computer and use it in GitHub Desktop.
Parse url for querystrings
"""
`furl` is really nice, but if it's only used for easily grabbing querstrings, you can use the `urlib.parse` module instead.
"""
url = "http://www.test.com?some_qs_here=asdf"
# Instead of this...
from furl import furl
parsed_url = furl(url)
some_qs_here = parsed_url.args["some_qs_here"]
# Just do this...
from urllib import parse
querystrings = dict(parse.parse_qs(parse.urlsplit(url).query))
some_qs_here = querystrings["some_qs_here"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment