My code in Python3:
import requests
URL = "http://xxx.xxx.com/querytext"
try:
text = urllib.parse.quote_plus(text)
r = requests.get(URL, params={"text": text}, auth=("guest", "1234"))
r_json = r.json()
except Exception:
return None
tag_results = r_json["data"]["result"]
My 'text' may contain some special characters so I want to do url encoding, as shown above. However, for one testing example, if I don't use this line:
text = urllib.parse.quote_plus(text)
I can get the expected result. Otherwise, I can't. So i suspect my way of using url encoding is wrong. What's wrong exactly?
One example of the text could be '#Thisisgreat#, yes!'