Reputation: 821
connection = urllib.request.urlopen("http://www.wdyl.com/profanity?q=" + text_to_check)
I don't know why but the code above is not working in python 3.5 and after several hours of searching i yet to find any answer for that. What i want to do is adding text_to_check string in the end of url
The error i'm receiving is:
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
Upvotes: 0
Views: 68
Reputation: 212835
The problem is your text_to_check
.
Try this:
query = urllib.parse.urlencode({'q': text_to_check})
urllib.request.urlopen("http://www.wdyl.com/profanity?" + query)
and print
the query
variable to see what has to happen with your "full of text from a .txt file" in order to work correctly as a URL.
Upvotes: 1