Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: c4ooo on October 18, 2015, 02:52:29 pm

Title: Google translate in java.
Post by: c4ooo on October 18, 2015, 02:52:29 pm
I wanted to add languge translating to my bot. Since google made all their APIs paid, using them is no longer an option. Therefore i tried to do what i did for the spellcheck bot: request the html for a google page with all the parameters in the url. There is a problem however, the google translate page relies on javascript to read the params in the url and [presumably] make the required http[?] calls to google servers. Therefore i cant just parse the returned hrml output for an answer.
Could any one help with reverse engineering the page to figure out what the calls would be? To be truthfull, i dont even know how to use http calls; sorunome started explaining them to me a long time ago but i never had time to finish his lecture :P
Title: Re: Google translate in java.
Post by: Sorunome on October 18, 2015, 03:31:50 pm
you need to set an http-header to make google think that the request came from a normal browser. Try making a normal request from your browser to google and inspect the network traffic and try setting the http headers to those.
Just so you know, this is against the TOS of google ;)
Title: Re: Google translate in java.
Post by: pimathbrainiac on October 19, 2015, 09:03:22 am
Or you can use the Bing translate API

EDIT: That one is paid as well. Oops...
Title: Re: Google translate in java.
Post by: c4ooo on October 19, 2015, 03:16:32 pm
Well i did figure it out: the client requests a page with the url "https://translate.google.com/translate_a/<Params here>", which contains the data in a format like this: http://pastebin.com/PuZpV2my
But the whole idea is against the google TOS, and like a majority of the requests are blocked :/
Title: Re: Google translate in java.
Post by: Eeems on October 19, 2015, 03:29:38 pm
I'd like to point you to ourl.ca/rules on this matter. We do not endorse breaking googles TOS.