C
C
Cyril2017-12-03 09:09:11
Google
Cyril, 2017-12-03 09:09:11

Is it possible to parse translation results from Google translator?

There was a task (instantly) to receive translation of any word at induction of the cursor of the mouse. I decided to look towards Google-translator. Using the official API of this translator costs money, and there will be a lot of words every day, because. there will be many users.
The bottom line is that on hover, the JavaScript code accesses the PHP script, passing it parameters such as the original language, the language of the result, and the word itself. The PHP script itself makes a GET request at the URL below to Google Translate. In response, it receives html content, which then parses and returns only the translation to the JavaScript code (one word, for example).
On reflection, I decided why not parse the results of the translation, for example, in PHP? The Google Translate address bar looks like this:

https://translate.google.ru/#<язык_оригинала>/<язык_перевода>/<слово>

For example, a call to https://translate.google.ru/#en/ru/Toaster will translate the English word "Toaster" into Russian.
The ID of the container with the result of the translation is #result_box . I think it's certainly possible to parse the resulting web page by extracting only the result in the #result_box block .
Has anyone tried it? Won't Google determine from a large number of IP hits that a parser is being used?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
sim3x, 2017-12-03
@sim3x

https://cloud.google.com/translate/docs/
https://chrome.google.com/webstore/detail/google-d...
Stupidly, Google will not parse itself
The fact that the page is accessed not by the user, but script, sites have long been determined by dozens of parameters, in which the SP does not always have a lot of weight.

D
Dimonchik, 2017-12-03
@dimonchik2013

1) Yandex
2) parse the code of applications / add-ons for browsers with functionality

T
ThunderCat, 2017-12-03
@ThunderCat

https://chrome.google.com/webstore/detail/myvocabu...
someone has already done it, repeat or use it.

E
Elisey Vlasenko, 2020-04-08
@homus32

https://translate.googleapis.com/translate_a/singl...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question