4

What is the Python2.7 equivalent to

from urllib.parse import urlparse, parse_qs
parsed_url = urlparse(url)
params = parse_qs(parsed_url.query)

I get

>>> from urllib.parse import urlparse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named parse

Thanks!

Colin 't Hart
  • 7,372
  • 3
  • 28
  • 51
Cranjis
  • 1,590
  • 8
  • 31
  • 64
  • 2
    You literally have not searched for "urlparse python2". Why? – Tomalak Jun 01 '18 at 07:41
  • @Tomalak Googled but didn't find parse_qs equivalent – Cranjis Jun 01 '18 at 07:53
  • 1
    When you Google "urlparse python2" it's the *first hit*. You may type use CTRL+F to find "parse_qs" on the documentation page. It's not that they have hidden that anywhere. – Tomalak Jun 01 '18 at 07:56

1 Answers1

11

In python2 use

from urlparse import urlparse, parse_qs
parsed_url = urlparse(url)
params = parse_qs(parsed_url.query)
Rakesh
  • 81,458
  • 17
  • 76
  • 113