A
A
alekssamos2019-10-30 14:19:53
JavaScript
alekssamos, 2019-10-30 14:19:53

Get key/id (SID) from translator page?

How to automate this? No matter how much I tried to look at the code, I did not understand how it is generated.
It is always different and works 7 days.
I know about the API. But in the browser it's free and the quality is better.
1. Go to the page translate.yandex.ru in a browser on your computer;
2. Write to the translator, for example, "hello" or "Hello";
3. Open the developer tools, for example, by pressing F12 on the keyboard or through the menu;
transltoolsstriptop.png
4. On the Network / Network / XHR / HTTP Requests tab, find a POST request with the following URL:

https://
translate.yandex.net/api/v1/tr.json/
translate?id=<b>c9883c4d.5da9f696.8329d0a3-1-0</b>
&amp;srv=tr-text&amp;lang=en-ru&amp;reason=auto

The desired value is highlighted in bold (after id= and before &),
If there are no requests, refresh the page with the F5 button.
transltoolsstrip.png
Right click > copy address
transltoolsstriptopcopylink.png
Example for Mozilla Firefox Console, Developer Tools:
ytrurlff.png
ytrurlffcopylink.png
Note: You can also use Fiddler or Charles Proxy;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xotkot, 2020-06-08
@alekssamos

everything is quite simple
there, parse the site translate.yandex.ru for the occurrence of SID , it will have a value consisting of three elements separated by dots, and so, each element just needs to be turned over, for example:
we have SID
49e65bdb.7fe1ede5.c76a5739
we get ID
bdb56e94.5ede1ef7.9375a67c

D
Dimonchik, 2019-10-30
@dimonchik2013

it is generated by a hash function
when the limits or frequency of requests are exceeded or when Selenium is not masked - there will be a captcha or an error (I don’t remember what status)
but pulling it out of the loaded page is a trivial task, for Selenium for sure

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question