Reputation: 174
When I am doing request using different browser it is giving me proper xml response.
http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=test&gl=US
Now I am request above url using curl command but it is giving me 400 error:
curl http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=test&gl=US
Also I have passed user-agent but it is also giving me same error.
curl -A "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0" http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=test&gl=US
Please guide If I missing somethings.
ERROR
400. That’s an error.
Your client has issued a malformed or illegal request. That’s all we know.
When I am trying below command:
curl -v -A "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0" -H "Accept: application/xml" -H "Content-Type: application/xml" https://suggestqueries.google.com/complete/search?hl=en&q=test&gl=US&format=rich
Then getting response:
SSL certificate verify ok.
GET /complete/search?hl=en HTTP/1.1
Content-Type: application/xml
HTTP/1.1 200 OK
Alternate-Protocol: 443:quic,p=0.002
Connection #0 to host suggestqueries.google.com left intact
SSLv3, TLS alert, Client hello (1):
Done curl -v -A "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0" -H "Accept: application/xml" -H "Content-Type: application/xml" https://suggestqueries.google.com/complete/search?hl=en
Upvotes: 1
Views: 2925
Reputation: 418
You have to put the url in quotes, try:
curl 'http://suggestqueries.google.com/complete/search?output=toolbar&hl=en&q=test&gl=US'
the & is treated specially in most shells.
As you can see in the error you posted, the url is cut before the first &:
Done curl -v -A "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0)
Gecko/20100101 Firefox/27.0" -H "Accept: application/xml" -H "Content-Type:
application/xml" https://suggestqueries.google.com/complete/search?hl=en
^
|
Upvotes: 0
Reputation: 316
Get wireshark and check the packages. It could be useless because I can see that curl use SSL. However you can check if your browser use SSL too. If not you get the full package that you can compare to curl output and find out which field cause error(check responses from google too, they may vary not only by 400 response).
Upvotes: 0