current position:Home>Python advanced: [Baidu translation reverse] graphic and video teaching!!!

Python advanced: [Baidu translation reverse] graphic and video teaching!!!

2022-01-29 23:36:11 Skin shrimp

Little knowledge , Great challenge ! This article is participating in “   A programmer must have a little knowledge   ” Creative activities

This article also participates in  「 Digging force Star Program 」  , Win a creative gift bag , Challenge creation incentive fund

Code Pipi shrimp A simple and interesting boy with sand sculpture , Like most of my friends, I like listening to music 、 game , Of course, in addition to this, there is an interest in writing ,emm..., It's a long time , Let's work hard together

If you think it's good , The ball is a concern

Open Baidu translation


Reverse analysis

Open control bar , Enter a word in the input box , You can see the corresponding request on the right , The request received the result of translation


below , Let's study this request

First of all, introduce the eyes , You can see , The request is POST request , Then there must be a requester


You can see that the following is the request body , Let's analyze it individually


 #  From what language to what language 
 from: en
 to: zh
 #  Words to be translated 
 query: love
 transtype: realtime
 simple_means_flag: 3
 #  The key is the following two 
 sign: 198772.518981
 token: e8ee595fdb9a062d2d41124d778ebd79
 domain: common
 Copy code 

Change one to translate , Comparing the above and below, we can find ,token Value has not changed , however sign Changed the

Try a few more , Can be determined ,sign Follow the translation and make changes ,token Fixed


analysis sign

Search for v2transapi, Because this request will be initiated every time to obtain the translation results , So we search this keyword



Breaking point , Refresh request to see

You can see , Stopped here , It shows that our thinking is right


You can see , The data of the request body comes from the above , So we're in sign Place a breakpoint , Go in and have a look sign How it was generated


It can be seen through JS The final result of encryption and other operations , But there is a key value involved , That's it window[l], We won't look at that , To analyze token


analysis token

so ,token It's through window.common.token Acquired , How do we know what this is


Don't worry , If you don't make up your mind, search


You can know ,token It turned out that it was generated when visiting the page , No wonder it's fixed


Search the page for token, You can also find the following window.gtk


Little buddy, do you remember there was a window[l], I'll compare the picture directly , After reading the picture below, I understand everything


Train of thought

  1. First , We need to get token Values and gtk, These are the values to be used later
  2. Generate sign, Can copy JS, utilize python Library manipulation js, Pass parameter generation sign
  3. The beginning of the simulation POST request , Get translation results
  4. end

Video teaching

Life is so nourishing ? Hard core works :【 Baidu translation JS reverse 】, Nanny class course , You deserve it !_ Bili, Bili _bilibili

Do not change your name , Don't change your family name , All over the network Code Pipi shrimp , I think it's good , The ball has a one button three in a row , ha-ha



I am a Code Pipi shrimp , A lover of sharing knowledge Shrimp lovers , In the future, we will continue to update blog posts that are beneficial to you , We look forward to your attention !!!

It's not easy to create , If this blog post is helpful to you , I hope you guys can connect three times with one button !, Thank you for your support , See you next time ~~~

 One key, three links .png

copyright notice
author[Skin shrimp],Please bring the original link to reprint, thank you.

Random recommended