Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

400 Bad request on text with \n #2

Open
theonlydoo opened this issue Sep 22, 2017 · 2 comments
Open

400 Bad request on text with \n #2

theonlydoo opened this issue Sep 22, 2017 · 2 comments

Comments

@theonlydoo
Copy link

I can't send newline in input to jamaicanize a huge text :

./jamaicanize.py "my ham is \n rich"
Traceback (most recent call last):
  File "./jamaicanize.py", line 20, in <module>
    html = urlopen("http://www.jamaicantranslator.com/?english=" + sentence)
  File "/usr/lib64/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib64/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
@vgallissot
Copy link
Owner

You must see that as a wrapper instead of a cli.
Everything you cannot send to http://www.jamaicantranslator.com won't work from this tool neither.

I just can suggest you call it for each line you need ;)
BR

@vgallissot
Copy link
Owner

I'd be a good enhancement to:

  1. encode input text so that it could be send over HTTP GET requests. I tried it with html.escape but doesn't seem to work.
  2. Add a try-catch so unsupported request can fail cleanly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants