Author Topic: Google translate in java.  (Read 3197 times)

0 Members and 1 Guest are viewing this topic.

Offline c4ooo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
Google translate in java.
« 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
-German Kuznetsov
The impossible chemical compound.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Google translate in java.
« Reply #1 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 ;)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
Re: Google translate in java.
« Reply #2 on: October 19, 2015, 09:03:22 am »
Or you can use the Bing translate API

EDIT: That one is paid as well. Oops...
« Last Edit: October 19, 2015, 09:11:36 am by pimathbrainiac »
I am Bach.

Offline c4ooo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
Re: Google translate in java.
« Reply #3 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 :/
-German Kuznetsov
The impossible chemical compound.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6265
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Google translate in java.
« Reply #4 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.
/e