2

There's this website: yamli.com which provides a form to transcript latin to arabic words.

I checked the source code and found out that it uses an HTML form:

<form id="search_form" action="http://api.yamli.com/search.ashx" method="get" >

The input I'm interested in is:

<input id="search_input" name="q" type="text" dir="rtl" size="60" maxlength="2048" autocomplete="off" tabindex="1"/>

So it's q.

My curl request is: curl -X POST -d "q=test" http://yamli.com/search.ashx -o /tmp/response

But the result seems to be a 3xx code, telling me that the page has moved (... and if curl is used with redirect it redirects to the main webpage):

    <head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found <a HREF="http://www.yamli.com/">here</a></body>

Is there anything I'm missing here?

2

This not a problem with curl. In your form, you have method="get" and because you use POST, you actually get the message:

405 - HTTP verb used to access this page is not allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.

Just use GET as required:

curl http://api.yamli.com/search.ashx?q=test

You may also have to provide valid cookies sent by the site.

  • I tried what you said, but I get a similar result: <head><title>Document Moved</title></head> <body><h1>Object Moved</h1>This document may be found <a HREF="http://www.yamli.com/?q=test">here</a></body – J. Doe Aug 6 '17 at 10:14
  • @J.Doe Just follow the redirects. They don't mean that does not work. – xhienne Aug 6 '17 at 10:46
  • Yes, sure. I used the -L option to follow redirects but the curl then just outputs the source code of the mail page... – J. Doe Aug 6 '17 at 10:49
  • EDIT: main* page – J. Doe Aug 6 '17 at 11:11
  • That means that it works since you don't have the error 405 I got with the POST method. What makes you think that the HTTP request you provide us with should return valid results without any additional parameters nor the cookies sent by yamli.com? Is that a use that Yamli is likely to disagree with? (i.e. they may try to keep you from using their site that way) – xhienne Aug 6 '17 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.