Parsing A URL With Python URLParse Parse_qs
<p>This was working with python 2.7 but wont work in 3.5 </p>

<p>I am trying to split a url's params then change out one of the params with a new value that is an md5 hash. </p>

<p>The urlbreaks down like this,</p>

<pre><code>ParseResult(scheme='http', netloc='example.com', path='/dynamic', params='', query='t=MD5-YOUR-OAUTH-TOKEN&amp;p=11111111', fragment='')
</code></pre>

<p>The new url should look like this,</p>

<pre><code>newString = 'http://example.com/dynamic?t='+tokenHashed+'&amp;p=11112311312'

import requests, json, hashlib
import urllib
from urllib.parse import urlparse
from xml.etree import ElementTree

        product_url = item.find('product_url').text
        parsed = urlparse(product_url)
        qs = urlparse.parse.parse_qs(parsed.query)
        qs['t'] = [tokenHashed]
        newqs = urllib.urlencode(qs, doseq=1)
        newurl = urlparse.urlunparse([newqs if i == 4 else x for i,x in enumerate(parsed)])



 print(newurl)
</code></pre>

<p>I get this error,</p>

<pre><code>'function' object has no attribute 'parse'
</code></pre>

<p>full stack trace</p>

<pre><code>Environment:


Request Method: POST
Request URL: http://localhost:8000/serviceapp/example/

Django Version: 1.8.8
Python Version: 3.5.1
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tastypie',
'haystack',
'serviceapp']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']


Traceback:
File "/Applications/AMPPS/www/djang-rest/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Applications/AMPPS/www/djang-rest/restapi/serviceapp/views.py" in example
  20.         getProdcuts(advertiserName)
File "/Applications/AMPPS/www/djang-rest/restapi/serviceapp/views.py" in getProdcuts
  42.         qs = urlparse.parse.parse_qs(parsed.query)

Exception Type: AttributeError at /serviceapp/example/
Exception Value: 'function' object has no attribute 'parse'
</code></pre>

<p>Is this a problem with my python version?</p>