For Python 3 you could try using quote
instead of quote_plus
:
import urllib.parse
print(urllib.parse.quote("http://www.sample.com/"))
Result:
http%3A%2F%2Fwww.sample.com%2F
Or:
from requests.utils import requote_uri
requote_uri("http://www.sample.com/?id=123 abc")
Result:
'https://www.sample.com/?id=123%20abc'