爬蟲呼叫百度翻譯API

Dictator丶發表於2019-01-14

1. 分析

1.1 尋找點選翻譯時傳送的請求

按照圖示操作,發現在輸入文字點選翻譯之後,一共傳送了四個請求。

爬蟲呼叫百度翻譯API

分別點開三個檢視返回響應,可以發現有用的為第一個langdetect和第四個v2transapi

  • langdetect

    第一個響應請求資訊

    請求方式為post, 引數為

    query: 你好
    複製程式碼

    請求響應為:

    {"error":0,"msg":"success","lan":"zh"}
    複製程式碼

    返回值 lan 為 zh,由此推斷改請求是返回需要翻譯的語言的型別。

  • v2transapi

    第四個響應請求資訊

    請求方式為 post,引數為

    from: zh
    to: en
    query: 你好
    transtype: realtime
    simple_means_flag: 3
    sign: 232427.485594
    token: f62805d95edecfe9fbd537179f6a147d
    複製程式碼

    請求的響應為:

    {"trans_result":{"from":"zh","to":"en","domain":"all","type":2,"status":0,"data":[{"dst":"Hello","prefixWrap":0,"src":"\u4f60\u597d","relation":[],"result":[[0,"Hello",["0|6"],[],["0|6"],["0|5"]]]}]},"dict_result":{"edict":"","zdict":{"simple":{"chenyu":null,"means":[{"pinyin":"n\u01d0 h\u01ceo","exp":[{"des":[{"main":"[how do you do;how are you;hello] \u7528\u4e8e\u6709\u793c\u8c8c\u7684\u6253\u62db\u547c\u6216\u8868\u793a\u4e0e\u4eba\u89c1\u9762\u65f6\u7684\u95ee\u5019","sub":[]}],"pos":""}]}]},"word":"\u4f60\u597d","detail":null},"from":"kingsoft","simple_means":{"word_name":"\u4f60\u597d","from":"kingsoft","word_means":["hello","hi","How do you do!"],"items":[""],"symbols":[{"word_symbol":"n\u01d0 h\u01ceo","parts":[{"part_name":"","means":[{"has_mean":1,"means":["\u6253\u62db\u547c","\u54c8\u55bd\uff0c\u5582","\u4f60\u597d\uff0c\u60a8\u597d","\u8868\u793a\u95ee\u5019"],"text":"hello","part":"int.","split":"1","word_mean":"hello"},{"has_mean":1,"means":["\uff08\u7528\u4f5c\u95ee\u5019\u8bed\uff09\u563f\uff0c\u5582"],"text":"hi","part":"int.","split":"1","word_mean":"hi"},{"has_mean":1,"means":["\u4f60\u597d\uff01"],"text":"How do you do!","part":"st.","split":"0","word_mean":"How do you do!"}]}],"symbol_mp3":""}],"is_CRI":0},"synthesize_means":{"symbols":[{"cys":[{"means":[{"mean_id":"12614","cy_id":"11478","part_id":null,"word_mean":"how do you do; how are you; hello"}]}],"symbol_id":"11714","xg":"","parts":[],"word_symbol":"n\u01d0 h\u01ceo","word_id":"11638"}],"word_name":"\u4f60\u597d","word_id":"11638"},"lang":"0"},"liju_result":{"double":"[[[[\"\\u6211\",\"w_0\",\"w_0,w_1,w_11,w_12\",0],[\"\\u662f\",\"w_1\",\"w_0,w_1,w_11,w_12\",0],[\"\\u4e3a\\u4e86\",\"w_2\",\"w_2,w_17\",0],[\"\\u4f60\\u597d\",\"w_3\",\"w_3,w_18,w_19,w_20\",1],[\"\\u624d\",\"w_4\",\"w_4,w_13\",0],[\"\\u8ddf\",\"w_5\",\"w_5,w_14\",0],[\"\\u4f60\",\"w_6\",\"w_6,w_15\",0],[\"\\u8bf4\",\"w_7\",\"w_7,w_14\",0],[\"\\u8fd9\\u4e2a\",\"w_8\",\"w_8,w_16\",0],[\"\\u7684\",\"w_9\",\"w_9\",0],[\"\\uff01\",\"w_10\",\"w_10,w_21\",0]],[[\"I\",\"w_11\",\"w_0,w_1,w_11,w_12\",0],[\"'m\",\"w_12\",\"w_0,w_1,w_11,w_12\",0,\" \"],[\"only\",\"w_13\",\"w_4,w_13\",0,\" \"],[\"telling\",\"w_14\",\"w_7,w_14\",0,\" \"],[\"you\",\"w_15\",\"w_6,w_15\",0,\" \"],[\"this\",\"w_16\",\"w_8,w_16\",0,\" \"],[\"for\",\"w_17\",\"w_2,w_17\",0,\" \"],[\"your\",\"w_18\",\"w_3,w_18,w_19,w_20\",0,\" \"],[\"own\",\"w_19\",\"w_3,w_18,w_19,w_20\",0,\" \"],[\"good\",\"w_20\",\"w_3,w_18,w_19,w_20\",0],[\"!\",\"w_21\",\"w_10,w_21\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",26578],[[[\"\\u201c\",\"w_44\",\"w_44,w_59\",0],[\"\\u4f60\\u597d\",\"w_45\",\"w_45,w_60,w_61\",1],[\"\\u5417\",\"w_46\",\"w_46,w_62\",0],[\"\\uff1f\",\"w_47\",\"w_47,w_63\",0],[\"\\u201d\",\"w_48\",\"w_48,w_64\",0],[\"\\u2014\",\"w_49\",\"w_49,w_65,w_66\",0],[\"\\u201c\",\"w_50\",\"w_50,w_67\",0],[\"\\u597d\",\"w_51\",\"w_51,w_68\",0],[\"\\uff0c\",\"w_52\",\"w_52\",0],[\"\\u770b\\u89c1\",\"w_53\",\"w_53,w_70\",0],[\"\\u4f60\",\"w_54\",\"w_54,w_71\",0],[\"\\u66f4\\u597d\",\"w_55\",\"w_55,w_68\",0],[\"\\u4e86\",\"w_56\",\"w_56\",0],[\"\\u3002\",\"w_57\",\"w_57,w_72\",0],[\"\\u201d\",\"w_58\",\"w_58,w_73\",0]],[[\"'\",\"w_59\",\"w_44,w_59\",0],[\"How\",\"w_60\",\"w_45,w_60,w_61\",0,\" \"],[\"are\",\"w_61\",\"w_45,w_60,w_61\",0,\" \"],[\"you\",\"w_62\",\"w_46,w_62\",0],[\"?\",\"w_63\",\"w_47,w_63\",0],[\"'\",\"w_64\",\"w_48,w_64\",0,\" \"],[\"\\u2014\",\"w_65\",\"w_49,w_65,w_66\",0],[\"'All\",\"w_66\",\"w_49,w_65,w_66\",0,\" \"],[\"the\",\"w_67\",\"w_50,w_67\",0,\" \"],[\"better\",\"w_68\",\"w_55,w_68\",0,\" \"],[\"for\",\"w_69\",\"\",0,\" \"],[\"seeing\",\"w_70\",\"w_53,w_70\",0,\" \"],[\"you\",\"w_71\",\"w_54,w_71\",0],[\".\",\"w_72\",\"w_57,w_72\",0,\" \"],[\"'\",\"w_73\",\"w_58,w_73\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",2311],[[[\"\\u591a\\u65e5\",\"w_104\",\"w_104,w_112\",0],[\"\\u4e0d\",\"w_105\",\"w_105,w_113\",0],[\"\\u89c1\",\"w_106\",\"w_106,w_114\",0],[\"\\u4e86\",\"w_107\",\"w_107\",0],[\"\\uff0c\",\"w_108\",\"w_108,w_120\",0],[\"\\u4f60\\u597d\",\"w_109\",\"w_109,w_121,w_122,w_123\",1],[\"\\u5417\",\"w_110\",\"w_110,w_111,w_124\",0],[\"\\uff1f\",\"w_111\",\"w_110,w_111,w_124\",0]],[[\"Haven\",\"w_112\",\"w_104,w_112\",0],[\"'t\",\"w_113\",\"w_105,w_113\",0,\" \"],[\"seen\",\"w_114\",\"w_106,w_114\",0,\" \"],[\"you\",\"w_115\",\"w_110,w_115\",0,\" \"],[\"for\",\"w_116\",\"\",0,\" \"],[\"a\",\"w_117\",\"\",0,\" \"],[\"long\",\"w_118\",\"\",0,\" \"],[\"time\",\"w_119\",\"\",0],[\".\",\"w_120\",\"w_108,w_120\",0,\" \"],[\"How\",\"w_121\",\"w_109,w_121,w_122,w_123\",0,\" \"],[\"are\",\"w_122\",\"w_109,w_121,w_122,w_123\",0,\" \"],[\"you\",\"w_123\",\"w_109,w_121,w_122,w_123\",0],[\"?\",\"w_124\",\"w_110,w_111,w_124\",0]],\"\\u300a\\u6c49\\u82f1\\u5927\\u8bcd\\u5178\\u300b\",82689],[[[\"\\u65f6\\u95f4\",\"w_146\",\"w_146,w_147,w_148,w_157,w_158\",0],[\"\\u4e0d\",\"w_147\",\"w_146,w_147,w_148,w_157,w_158\",0],[\"\\u65e9\",\"w_148\",\"w_146,w_147,w_148,w_157,w_158\",0],[\"\\u4e86\",\"w_149\",\"w_149\",0],[\"\\uff0c\",\"w_150\",\"w_150,w_159\",0],[\"\\u4f60\\u597d\",\"w_151\",\"w_151,w_160,w_161\",1],[\"\\u8d70\",\"w_152\",\"w_152,w_163,w_164\",0],[\"\\u4e86\",\"w_153\",\"w_153\",0],[\"\\u3002\",\"w_154\",\"w_154,w_165\",0]],[[\"It\",\"w_155\",\"w_146,w_155\",0],[\"'s\",\"w_156\",\"\",0,\" \"],[\"getting\",\"w_157\",\"w_146,w_147,w_148,w_157,w_158\",0,\" \"],[\"late\",\"w_158\",\"w_146,w_147,w_148,w_157,w_158\",0],[\".\",\"w_159\",\"w_150,w_159\",0,\" \"],[\"You\",\"w_160\",\"w_151,w_160,w_161\",0,\" \"],[\"ought\",\"w_161\",\"w_151,w_160,w_161\",0,\" \"],[\"to\",\"w_162\",\"\",0,\" \"],[\"get\",\"w_163\",\"w_152,w_163,w_164\",0,\" \"],[\"going\",\"w_164\",\"w_152,w_163,w_164\",0],[\".\",\"w_165\",\"w_154,w_165\",0]],\"\\u300a\\u6c49\\u82f1\\u5927\\u8bcd\\u5178\\u300b\",78331],[[[\"\\u55e8\",\"w_186\",\"w_186,w_191\",0],[\"\\uff0c\",\"w_187\",\"w_187,w_192\",0],[\"\\u4f60\\u597d\",\"w_188\",\"w_188,w_191\",1],[\"\\u5417\",\"w_189\",\"w_189,w_195\",0],[\"\\uff1f\",\"w_190\",\"w_190,w_196\",0]],[[\"Hiya\",\"w_191\",\"w_188,w_191\",0],[\".\",\"w_192\",\"w_187,w_192\",0,\" \"],[\"How\",\"w_193\",\"\",0,\" \"],[\"are\",\"w_194\",\"\",0,\" \"],[\"you\",\"w_195\",\"w_189,w_195\",0],[\"?\",\"w_196\",\"w_190,w_196\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",29190],[[[\"\\u4f60\\u597d\",\"w_208\",\"w_208,w_217\",1],[\"\\uff0c\",\"w_209\",\"w_209,w_219\",0],[\"\\u5f17\\u857e\\u8fea\",\"w_210\",\"w_210,w_218\",0],[\"\\uff01\",\"w_211\",\"w_211,w_217\",0],[\"\\u662f\",\"w_212\",\"w_212,w_221\",0],[\"\\u6211\",\"w_213\",\"w_213,w_223\",0],[\"\\uff0c\",\"w_214\",\"w_214,w_224\",0],[\"\\u739b\\u514b\\u8f9b\",\"w_215\",\"w_215,w_225\",0],[\"\\u3002\",\"w_216\",\"w_216,w_226\",0]],[[\"Hello\",\"w_217\",\"w_211,w_217\",0,\" \"],[\"Freddy\",\"w_218\",\"w_210,w_218\",0],[\",\",\"w_219\",\"w_209,w_219\",0,\" \"],[\"it\",\"w_220\",\"\",0],[\"'s\",\"w_221\",\"w_212,w_221\",0,\" \"],[\"only\",\"w_222\",\"\",0,\" \"],[\"me\",\"w_223\",\"w_213,w_223\",0],[\",\",\"w_224\",\"w_214,w_224\",0,\" \"],[\"Maxine\",\"w_225\",\"w_215,w_225\",0],[\".\",\"w_226\",\"w_216,w_226\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",32643],[[[\"\\u7535\\u8bdd\",\"w_246\",\"w_246,w_247,w_267\",0],[\"\\u7ebf\\u8def\",\"w_247\",\"w_246,w_247,w_267\",0],[\"\\u4e0d\",\"w_248\",\"w_248,w_261,w_262,w_263\",0],[\"\\u592a\",\"w_249\",\"w_249,w_265\",0],[\"\\u597d\",\"w_250\",\"w_250,w_266\",0],[\"\\u3002\",\"w_251\",\"w_251,w_268\",0],[\"\\u82cf\\u73ca\",\"w_252\",\"w_252,w_274\",0],[\"\\uff0c\",\"w_253\",\"w_253\",0],[\"\\u6211\\u4eec\",\"w_254\",\"w_254,w_270\",0],[\"\\u518d\",\"w_255\",\"w_255,w_273\",0],[\"\\u6253\",\"w_256\",\"w_256,w_257,w_271\",0],[\"\\u7ed9\",\"w_257\",\"w_256,w_257,w_271\",0],[\"\\u4f60\\u597d\",\"w_258\",\"w_258,w_272\",1],[\"\\u5417\",\"w_259\",\"w_259,w_273\",0],[\"\\uff1f\",\"w_260\",\"w_260,w_275\",0]],[[\"It\",\"w_261\",\"w_248,w_261,w_262,w_263\",0],[\"'s\",\"w_262\",\"w_248,w_261,w_262,w_263\",0,\" \"],[\"not\",\"w_263\",\"w_248,w_261,w_262,w_263\",0,\" \"],[\"a\",\"w_264\",\"\",0,\" \"],[\"very\",\"w_265\",\"w_249,w_265\",0,\" \"],[\"good\",\"w_266\",\"w_250,w_266\",0,\" \"],[\"line\",\"w_267\",\"w_246,w_247,w_267\",0],[\".\",\"w_268\",\"w_251,w_268\",0,\" \"],[\"Shall\",\"w_269\",\"\",0,\" \"],[\"we\",\"w_270\",\"w_254,w_270\",0,\" \"],[\"call\",\"w_271\",\"w_256,w_257,w_271\",0,\" \"],[\"you\",\"w_272\",\"w_258,w_272\",0,\" \"],[\"back\",\"w_273\",\"w_259,w_273\",0,\" \"],[\"Susan\",\"w_274\",\"w_252,w_274\",0],[\"?\",\"w_275\",\"w_260,w_275\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",35402],[[[\"\\u4f60\\u597d\",\"w_306\",\"w_306,w_311,w_312,w_313\",1],[\"\\u54c7\",\"w_307\",\"w_307,w_309\",0],[\"\\uff1f\",\"w_308\",\"w_308,w_314\",0]],[[\"Well\",\"w_309\",\"w_307,w_309\",0],[\",\",\"w_310\",\"\",0,\" \"],[\"how\",\"w_311\",\"w_306,w_311,w_312,w_313\",0,\" \"],[\"are\",\"w_312\",\"w_306,w_311,w_312,w_313\",0,\" \"],[\"you\",\"w_313\",\"w_306,w_311,w_312,w_313\",0],[\"?\",\"w_314\",\"w_308,w_314\",0]],\"\\u300a\\u6c49\\u82f1\\u5927\\u8bcd\\u5178\\u300b\",77128],[[[\"\\u201c\",\"w_324\",\"w_324,w_348\",0],[\"\\u563f\",\"w_325\",\"w_325,w_349\",0],[\"\\uff0c\",\"w_326\",\"w_326,w_351\",0],[\"\\u4f60\\u4eec\",\"w_327\",\"w_327,w_328,w_329,w_349\",0],[\"\\u597d\",\"w_328\",\"w_327,w_328,w_329,w_349\",0],[\"\\uff01\",\"w_329\",\"w_327,w_328,w_329,w_349\",0],[\"\\u201d\",\"w_330\",\"w_330,w_352\",0],[\"\\u90a3\\u4e2a\",\"w_331\",\"w_331,w_332,w_354,w_355\",0],[\"\\u5973\\u4eba\",\"w_332\",\"w_331,w_332,w_354,w_355\",0],[\"\\u7b11\",\"w_333\",\"w_333,w_334,w_357,w_358\",0],[\"\\u7740\",\"w_334\",\"w_333,w_334,w_357,w_358\",0],[\"\\u5bf9\",\"w_335\",\"w_335,w_354\",0],[\"\\u4ed6\\u4eec\",\"w_336\",\"w_336,w_359\",0],[\"\\u8bf4\",\"w_337\",\"w_337,w_353\",0],[\"\\u3002\",\"w_338\",\"w_338,w_360\",0],[\"\\u2014\\u2014\",\"w_339\",\"w_339,w_361\",0],[\"\\u201c\",\"w_340\",\"w_340,w_362\",0],[\"\\u4f60\\u597d\",\"w_341\",\"w_341,w_350\",1],[\"\\uff01\",\"w_342\",\"w_342,w_364\",0],[\"\\u201d\",\"w_343\",\"w_343,w_365\",0],[\"\\u4ed6\\u4eec\",\"w_344\",\"w_344,w_366\",0],[\"\\u9f50\\u58f0\",\"w_345\",\"w_345,w_346,w_347,w_367\",0],[\"\\u8bf4\",\"w_346\",\"w_345,w_346,w_347,w_367\",0],[\"\\u3002\",\"w_347\",\"w_345,w_346,w_347,w_367\",0]],[[\"'\",\"w_348\",\"w_324,w_348\",0],[\"Hello\",\"w_349\",\"w_327,w_328,w_329,w_349\",0,\" \"],[\"there\",\"w_350\",\"w_341,w_350\",0],[\",\",\"w_351\",\"w_326,w_351\",0],[\"'\",\"w_352\",\"w_330,w_352\",0,\" \"],[\"said\",\"w_353\",\"w_337,w_353\",0,\" \"],[\"the\",\"w_354\",\"w_335,w_354\",0,\" \"],[\"woman\",\"w_355\",\"w_331,w_332,w_354,w_355\",0],[\",\",\"w_356\",\"\",0,\" \"],[\"smiling\",\"w_357\",\"w_333,w_334,w_357,w_358\",0,\" \"],[\"at\",\"w_358\",\"w_333,w_334,w_357,w_358\",0,\" \"],[\"them\",\"w_359\",\"w_336,w_359\",0],[\".\",\"w_360\",\"w_338,w_360\",0,\" \"],[\"\\u2014\",\"w_361\",\"w_339,w_361\",0,\" \"],[\"'\",\"w_362\",\"w_340,w_362\",0],[\"Hi\",\"w_363\",\"\",0],[\"!\",\"w_364\",\"w_342,w_364\",0],[\"'\",\"w_365\",\"w_343,w_365\",0,\" \"],[\"they\",\"w_366\",\"w_344,w_366\",0,\" \"],[\"chorused\",\"w_367\",\"w_345,w_346,w_347,w_367\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",63380],[[[\"\\u54ce\\u5440\",\"w_412\",\"w_412,w_418\",0],[\"\\uff0c\",\"w_413\",\"w_413\",0],[\"\\u4f60\\u597d\",\"w_414\",\"w_414,w_419\",1],[\"\\uff0c\",\"w_415\",\"w_415,w_420\",0],[\"\\u6c64\\u59c6\",\"w_416\",\"w_416,w_421\",0],[\"\\u3002\",\"w_417\",\"w_417\",0]],[[\"Why\",\"w_418\",\"w_412,w_418\",0,\" \"],[\"hello\",\"w_419\",\"w_414,w_419\",0],[\",\",\"w_420\",\"w_415,w_420\",0,\" \"],[\"Tom\",\"w_421\",\"w_416,w_421\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",70716],[[[\"\\u201c\",\"w_432\",\"w_432,w_451\",0],[\"\\u4f60\\u597d\",\"w_433\",\"w_433,w_452\",1],[\"\\uff0c\",\"w_434\",\"w_434,w_453\",0],[\"\\u739b\\u4e3d\\u4e9a\",\"w_435\",\"w_435,w_454\",0],[\"\\uff0c\",\"w_436\",\"w_436,w_455\",0],[\"\\u201d\",\"w_437\",\"w_437,w_456\",0],[\"\\u4ed6\",\"w_438\",\"w_438,w_457\",0],[\"\\u8bf4\",\"w_439\",\"w_439,w_458\",0],[\"\\uff0c\",\"w_440\",\"w_440,w_459,w_460\",0],[\"\\u8fd9\",\"w_441\",\"w_441\",0],[\"\\u8ba9\",\"w_442\",\"w_442\",0],[\"\\u5979\",\"w_443\",\"w_443,w_461\",0],[\"\\u8138\",\"w_444\",\"w_444,w_462\",0],[\"\\u4e0a\",\"w_445\",\"w_445\",0],[\"\\u53c8\",\"w_446\",\"w_446,w_463\",0],[\"\\u6cdb\\u8d77\",\"w_447\",\"w_447,w_448,w_449,w_462\",0],[\"\\u4e86\",\"w_448\",\"w_447,w_448,w_449,w_462\",0],[\"\\u7ea2\\u6655\",\"w_449\",\"w_447,w_448,w_449,w_462\",0],[\"\\u3002\",\"w_450\",\"w_450\",0]],[[\"'\",\"w_451\",\"w_432,w_451\",0],[\"Hello\",\"w_452\",\"w_433,w_452\",0],[\",\",\"w_453\",\"w_434,w_453\",0,\" \"],[\"Maria\",\"w_454\",\"w_435,w_454\",0],[\",\",\"w_455\",\"w_436,w_455\",0],[\"'\",\"w_456\",\"w_437,w_456\",0,\" \"],[\"he\",\"w_457\",\"w_438,w_457\",0,\" \"],[\"said\",\"w_458\",\"w_439,w_458\",0],[\",\",\"w_459\",\"w_440,w_459,w_460\",0,\" \"],[\"and\",\"w_460\",\"w_440,w_459,w_460\",0,\" \"],[\"she\",\"w_461\",\"w_443,w_461\",0,\" \"],[\"blushed\",\"w_462\",\"w_447,w_448,w_449,w_462\",0,\" \"],[\"again\",\"w_463\",\"w_446,w_463\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",6738],[[[\"\\u4f60\\u597d\",\"w_496\",\"w_496,w_498\",1],[\"\\uff01\",\"w_497\",\"w_497,w_499\",0]],[[\"Hello\",\"w_498\",\"w_496,w_498\",0],[\"!\",\"w_499\",\"w_497,w_499\",0]],\"\\u300a\\u6c49\\u82f1\\u5927\\u8bcd\\u5178\\u300b\",78296],[[[\"\\u4f60\\u597d\",\"w_504\",\"w_504,w_513,w_514\",1],[\"\\uff0c\",\"w_505\",\"w_505,w_517\",0],[\"\\u4f2f\\u7eb3\\u5fb7\",\"w_506\",\"w_506,w_518\",0],[\"\\uff01\",\"w_507\",\"w_507,w_519\",0],[\"\\u89c1\\u5230\",\"w_508\",\"w_508,w_526\",0],[\"\\u4f60\",\"w_509\",\"w_509,w_527\",0],[\"\\u771f\",\"w_510\",\"w_510,w_520,w_521\",0],[\"\\u9ad8\\u5174\",\"w_511\",\"w_511,w_512,w_523,w_524\",0],[\"\\u3002\",\"w_512\",\"w_511,w_512,w_523,w_524\",0]],[[\"Good\",\"w_513\",\"w_504,w_513,w_514\",0,\" \"],[\"day\",\"w_514\",\"w_504,w_513,w_514\",0,\" \"],[\"to\",\"w_515\",\"\",0,\" \"],[\"you\",\"w_516\",\"\",0],[\",\",\"w_517\",\"w_505,w_517\",0,\" \"],[\"Bernard\",\"w_518\",\"w_506,w_518\",0],[\"!\",\"w_519\",\"w_507,w_519\",0,\" \"],[\"It\",\"w_520\",\"w_510,w_520,w_521\",0],[\"'s\",\"w_521\",\"w_510,w_520,w_521\",0,\" \"],[\"a\",\"w_522\",\"\",0,\" \"],[\"positive\",\"w_523\",\"w_511,w_512,w_523,w_524\",0,\" \"],[\"delight\",\"w_524\",\"w_511,w_512,w_523,w_524\",0,\" \"],[\"to\",\"w_525\",\"\",0,\" \"],[\"see\",\"w_526\",\"w_508,w_526\",0,\" \"],[\"you\",\"w_527\",\"w_509,w_527\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",46656],[[[\"\\u563f\",\"w_552\",\"w_552,w_556\",0],[\"\\uff0c\",\"w_553\",\"w_553\",0],[\"\\u4f60\\u597d\",\"w_554\",\"w_554,w_557,w_558,w_559,w_560\",1],[\"\\uff1f\",\"w_555\",\"w_555,w_561\",0]],[[\"Hello\",\"w_556\",\"w_552,w_556\",0],[\"!\",\"w_557\",\"w_554,w_557,w_558,w_559,w_560\",0,\" \"],[\"How\",\"w_558\",\"w_554,w_557,w_558,w_559,w_560\",0,\" \"],[\"are\",\"w_559\",\"w_554,w_557,w_558,w_559,w_560\",0,\" \"],[\"you\",\"w_560\",\"w_554,w_557,w_558,w_559,w_560\",0],[\"?\",\"w_561\",\"w_555,w_561\",0]],\"\\u300a\\u6c49\\u82f1\\u5927\\u8bcd\\u5178\\u300b\",77459],[[[\"\\u201c\",\"w_572\",\"w_572,w_589\",0],[\"\\u4f60\\u597d\",\"w_573\",\"w_573,w_590\",1],[\"\\uff0c\",\"w_574\",\"w_574,w_591\",0],[\"\\u6211\",\"w_575\",\"w_575,w_592\",0],[\"\\u60f3\",\"w_576\",\"w_576,w_595\",0],[\"\\u6211\\u4eec\",\"w_577\",\"w_577,w_596\",0],[\"\\u8fd8\",\"w_578\",\"w_578,w_579,w_593,w_594\",0],[\"\\u6ca1\\u6709\",\"w_579\",\"w_578,w_579,w_593,w_594\",0],[\"\\u89c1\\u8fc7\",\"w_580\",\"w_580,w_581,w_597,w_598\",0],[\"\\u5427\",\"w_581\",\"w_580,w_581,w_597,w_598\",0],[\"\\uff0c\",\"w_582\",\"w_582,w_599\",0],[\"\\u201d\",\"w_583\",\"w_583,w_600\",0],[\"\\u7f57\\u4f2f\\u7279\",\"w_584\",\"w_584,w_601\",0],[\"\\u81ea\\u6211\",\"w_585\",\"w_585,w_603\",0],[\"\\u4ecb\\u7ecd\",\"w_586\",\"w_586,w_602\",0],[\"\\u9053\",\"w_587\",\"w_587,w_603\",0],[\"\\u3002\",\"w_588\",\"w_588\",0]],[[\"'\",\"w_589\",\"w_572,w_589\",0],[\"Hello\",\"w_590\",\"w_573,w_590\",0],[\",\",\"w_591\",\"w_574,w_591\",0,\" \"],[\"I\",\"w_592\",\"w_575,w_592\",0,\" \"],[\"don\",\"w_593\",\"w_578,w_579,w_593,w_594\",0],[\"'t\",\"w_594\",\"w_578,w_579,w_593,w_594\",0,\" \"],[\"think\",\"w_595\",\"w_576,w_595\",0,\" \"],[\"we\",\"w_596\",\"w_577,w_596\",0],[\"'ve\",\"w_597\",\"w_580,w_581,w_597,w_598\",0,\" \"],[\"met\",\"w_598\",\"w_580,w_581,w_597,w_598\",0],[\",\",\"w_599\",\"w_582,w_599\",0],[\"'\",\"w_600\",\"w_583,w_600\",0,\" \"],[\"Robert\",\"w_601\",\"w_584,w_601\",0,\" \"],[\"introduced\",\"w_602\",\"w_586,w_602\",0,\" \"],[\"himself\",\"w_603\",\"w_587,w_603\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",69839],[[[\"\\u201c\",\"w_636\",\"w_636,w_646\",0],[\"\\u4f60\\u597d\",\"w_637\",\"w_637,w_647\",1],[\"\\uff0c\",\"w_638\",\"w_638,w_651\",0],[\"\\u8d1d\\u6797\\u5384\\u59c6\",\"w_639\",\"w_639,w_648,w_649,w_650\",0],[\"\\u592b\\u4eba\",\"w_640\",\"w_640,w_651,w_652\",0],[\"\\uff0c\",\"w_641\",\"w_641,w_654\",0],[\"\\u201d\",\"w_642\",\"w_642,w_655\",0],[\"\\u8428\\u59c6\",\"w_643\",\"w_643,w_656\",0],[\"\\u8bf4\",\"w_644\",\"w_644,w_657\",0],[\"\\u3002\",\"w_645\",\"w_645,w_658\",0]],[[\"'\",\"w_646\",\"w_636,w_646\",0],[\"How\",\"w_647\",\"w_637,w_647\",0,\" \"],[\"do\",\"w_648\",\"w_639,w_648,w_649,w_650\",0,\" \"],[\"you\",\"w_649\",\"w_639,w_648,w_649,w_650\",0,\" \"],[\"do\",\"w_650\",\"w_639,w_648,w_649,w_650\",0],[\",\",\"w_651\",\"w_640,w_651,w_652\",0,\" \"],[\"Mrs\",\"w_652\",\"w_640,w_651,w_652\",0,\" \"],[\"Bellingham\",\"w_653\",\"\",0],[\",\",\"w_654\",\"w_641,w_654\",0],[\"'\",\"w_655\",\"w_642,w_655\",0,\" \"],[\"Sam\",\"w_656\",\"w_643,w_656\",0,\" \"],[\"said\",\"w_657\",\"w_644,w_657\",0],[\".\",\"w_658\",\"w_645,w_658\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",29901],[[[\"\\u5582\",\"w_682\",\"w_682,w_692\",0],[\"\\uff0c\",\"w_683\",\"w_683,w_693\",0],[\"\\u4f60\\u597d\",\"w_684\",\"w_684,w_694,w_695\",1],[\"\\u3002\",\"w_685\",\"w_685,w_696\",0],[\"\\u4f60\",\"w_686\",\"w_686,w_697\",0],[\"\\u4e00\\u5b9a\",\"w_687\",\"w_687,w_698\",0],[\"\\u662f\",\"w_688\",\"w_688,w_699\",0],[\"\\u897f\\u5fb7\\u5c3c\",\"w_689\",\"w_689,w_690,w_700\",0],[\"\\u5427\",\"w_690\",\"w_689,w_690,w_700\",0],[\"\\u3002\",\"w_691\",\"w_691,w_701\",0]],[[\"Oh\",\"w_692\",\"w_682,w_692\",0],[\",\",\"w_693\",\"w_683,w_693\",0,\" \"],[\"hi\",\"w_694\",\"w_684,w_694,w_695\",0,\" \"],[\"there\",\"w_695\",\"w_684,w_694,w_695\",0],[\".\",\"w_696\",\"w_685,w_696\",0,\" \"],[\"You\",\"w_697\",\"w_686,w_697\",0,\" \"],[\"must\",\"w_698\",\"w_687,w_698\",0,\" \"],[\"be\",\"w_699\",\"w_688,w_699\",0,\" \"],[\"Sidney\",\"w_700\",\"w_689,w_690,w_700\",0],[\".\",\"w_701\",\"w_691,w_701\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",63381],[[[\"\\u6211\",\"w_722\",\"w_722,w_730\",0],[\"\\u591a\",\"w_723\",\"w_723\",0],[\"\\u5e0c\\u671b\",\"w_724\",\"w_724,w_731,w_732\",0],[\"\\u80fd\",\"w_725\",\"w_725,w_726,w_734\",0],[\"\\u5e26\\u7ed9\",\"w_726\",\"w_725,w_726,w_734\",0],[\"\\u4f60\\u597d\",\"w_727\",\"w_727,w_737\",1],[\"\\u6d88\\u606f\",\"w_728\",\"w_728,w_729,w_735\",0],[\"\\u3002\",\"w_729\",\"w_728,w_729,w_735\",0]],[[\"I\",\"w_730\",\"w_722,w_730\",0,\" \"],[\"wish\",\"w_731\",\"w_724,w_731,w_732\",0,\" \"],[\"I\",\"w_732\",\"w_724,w_731,w_732\",0,\" \"],[\"had\",\"w_733\",\"\",0,\" \"],[\"better\",\"w_734\",\"w_725,w_726,w_734\",0,\" \"],[\"news\",\"w_735\",\"w_728,w_729,w_735\",0,\" \"],[\"for\",\"w_736\",\"\",0,\" \"],[\"you\",\"w_737\",\"w_727,w_737\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",40519],[[[\"\\u4ed6\\u4eec\",\"w_754\",\"w_754,w_759\",0],[\"\\u90fd\",\"w_755\",\"w_755,w_760\",0],[\"\\u95ee\",\"w_756\",\"w_756,w_757,w_761,w_762,w_763,w_764\",0],[\"\\u4f60\\u597d\",\"w_757\",\"w_756,w_757,w_761,w_762,w_763,w_764\",1],[\"\\u3002\",\"w_758\",\"w_758,w_765\",0]],[[\"They\",\"w_759\",\"w_754,w_759\",0,\" \"],[\"all\",\"w_760\",\"w_755,w_760\",0,\" \"],[\"inquired\",\"w_761\",\"w_756,w_757,w_761,w_762,w_763,w_764\",0,\" \"],[\"after\",\"w_762\",\"w_756,w_757,w_761,w_762,w_763,w_764\",0,\" \"],[\"your\",\"w_763\",\"w_756,w_757,w_761,w_762,w_763,w_764\",0,\" \"],[\"health\",\"w_764\",\"w_756,w_757,w_761,w_762,w_763,w_764\",0],[\".\",\"w_765\",\"w_758,w_765\",0]],\"\\u300a\\u6c49\\u82f1\\u5927\\u8bcd\\u5178\\u300b\",90196],[[[\"\\u6211\",\"w_778\",\"w_778,w_798\",0],[\"\\u4f1a\",\"w_779\",\"w_779,w_799\",0],[\"\\u544a\\u8bc9\",\"w_780\",\"w_780,w_800\",0],[\"\\u7238\\u7238\",\"w_781\",\"w_781,w_801\",0],[\"\\uff0c\",\"w_782\",\"w_782,w_802\",0],[\"\\u5230\\u65f6\\u5019\",\"w_783\",\"w_783,w_803,w_804\",0],[\"\\u6709\",\"w_784\",\"w_784\",0],[\"\\u4f60\\u597d\",\"w_785\",\"w_785,w_805\",1],[\"\\u53d7\",\"w_786\",\"w_786,w_807\",0],[\"\\u7684\",\"w_787\",\"w_787\",0],[\"\\uff0c\",\"w_788\",\"w_788\",0],[\"\\u56e0\\u4e3a\",\"w_789\",\"w_789,w_809\",0],[\"\\u7238\\u7238\",\"w_790\",\"w_790,w_810\",0],[\"\\u4f1a\",\"w_791\",\"w_791,w_792,w_811\",0],[\"\\u518d\",\"w_792\",\"w_791,w_792,w_811\",0],[\"\\u63cd\",\"w_793\",\"w_793,w_806\",0],[\"\\u4f60\",\"w_794\",\"w_794,w_813\",0],[\"\\u4e00\",\"w_795\",\"w_795,w_814\",0],[\"\\u987f\",\"w_796\",\"w_796,w_816\",0],[\"\\u3002\",\"w_797\",\"w_797,w_808\",0]],[[\"I\",\"w_798\",\"w_778,w_798\",0],[\"'ll\",\"w_799\",\"w_779,w_799\",0,\" \"],[\"tell\",\"w_800\",\"w_780,w_800\",0,\" \"],[\"Daddy\",\"w_801\",\"w_781,w_801\",0],[\",\",\"w_802\",\"w_782,w_802\",0,\" \"],[\"and\",\"w_803\",\"w_783,w_803,w_804\",0,\" \"],[\"then\",\"w_804\",\"w_783,w_803,w_804\",0,\" \"],[\"you\",\"w_805\",\"w_785,w_805\",0],[\"'ll\",\"w_806\",\"w_793,w_806\",0,\" \"],[\"be\",\"w_807\",\"w_791,w_807\",0,\" \"],[\"sorry\",\"w_808\",\"w_797,w_808\",0,\" \"],[\"because\",\"w_809\",\"w_789,w_809\",0,\" \"],[\"he\",\"w_810\",\"w_790,w_810\",0],[\"'ll\",\"w_811\",\"w_791,w_792,w_811\",0,\" \"],[\"give\",\"w_812\",\"\",0,\" \"],[\"you\",\"w_813\",\"w_794,w_813\",0,\" \"],[\"another\",\"w_814\",\"w_795,w_814\",0,\" \"],[\"black\",\"w_815\",\"\",0,\" \"],[\"eye\",\"w_816\",\"w_796,w_816\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",58102],[[[\"\\u4ed6\\u4eec\",\"w_856\",\"w_856,w_870\",0],[\"\\u8981\\u662f\",\"w_857\",\"w_857,w_869\",0],[\"\\u5bf9\",\"w_858\",\"w_858,w_872\",0],[\"\\u4f60\\u597d\",\"w_859\",\"w_859,w_873\",1],[\"\\uff0c\",\"w_860\",\"w_860\",0],[\"\\u4e5f\",\"w_861\",\"w_861,w_874\",0],[\"\\u4e0d\\u8fc7\",\"w_862\",\"w_862,w_875\",0],[\"\\u662f\",\"w_863\",\"w_863,w_876\",0],[\"\\u4e3a\\u4e86\",\"w_864\",\"w_864,w_878\",0],[\"\\u8ba8\\u597d\",\"w_865\",\"w_865,w_879\",0],[\"\\u4f60\",\"w_866\",\"w_866,w_880\",0],[\"\\u7f62\\u4e86\",\"w_867\",\"w_867,w_877\",0],[\"\\u3002\",\"w_868\",\"w_868,w_882\",0]],[[\"If\",\"w_869\",\"w_857,w_869\",0,\" \"],[\"they\",\"w_870\",\"w_856,w_870\",0],[\"'d\",\"w_871\",\"\",0,\" \"],[\"treated\",\"w_872\",\"w_858,w_872\",0,\" \"],[\"you\",\"w_873\",\"w_859,w_873\",0,\" \"],[\"well\",\"w_874\",\"w_861,w_874\",0,\" \"],[\"it\",\"w_875\",\"w_862,w_875\",0,\" \"],[\"was\",\"w_876\",\"w_863,w_876\",0,\" \"],[\"just\",\"w_877\",\"w_867,w_877\",0,\" \"],[\"to\",\"w_878\",\"w_864,w_878\",0,\" \"],[\"soften\",\"w_879\",\"w_865,w_879\",0,\" \"],[\"you\",\"w_880\",\"w_866,w_880\",0,\" \"],[\"up\",\"w_881\",\"\",0],[\".\",\"w_882\",\"w_868,w_882\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",57858],[[[\"\\u201c\",\"w_910\",\"w_910,w_924\",0],[\"\\u4f60\\u597d\",\"w_911\",\"w_911,w_925\",1],[\"\\uff0c\",\"w_912\",\"w_912,w_926\",0],[\"\\u65af\\u65fa\\u68ee\",\"w_913\",\"w_913,w_927\",0],[\"\\u3002\",\"w_914\",\"w_914,w_928\",0],[\"\\u201d\",\"w_915\",\"w_915,w_929\",0],[\"\\u4ed6\",\"w_916\",\"w_916,w_930\",0],[\"\\u8bf4\\u8bdd\",\"w_917\",\"w_917,w_931\",0],[\"\\u7684\",\"w_918\",\"w_918\",0],[\"\\u65f6\\u5019\",\"w_919\",\"w_919,w_927\",0],[\"\\u5e76\\u672a\",\"w_920\",\"w_920,w_932\",0],[\"\\u663e\\u5f97\",\"w_921\",\"w_921,w_927\",0],[\"\\u60ca\\u8bb6\",\"w_922\",\"w_922,w_933\",0],[\"\\u3002\",\"w_923\",\"w_923,w_934\",0]],[[\"'\",\"w_924\",\"w_910,w_924\",0],[\"Hello\",\"w_925\",\"w_911,w_925\",0],[\",\",\"w_926\",\"w_912,w_926\",0,\" \"],[\"Swanson\",\"w_927\",\"w_921,w_927\",0],[\",\",\"w_928\",\"w_914,w_928\",0],[\"'\",\"w_929\",\"w_915,w_929\",0,\" \"],[\"he\",\"w_930\",\"w_916,w_930\",0,\" \"],[\"said\",\"w_931\",\"w_917,w_931\",0,\" \"],[\"without\",\"w_932\",\"w_920,w_932\",0,\" \"],[\"surprise\",\"w_933\",\"w_922,w_933\",0],[\".\",\"w_934\",\"w_923,w_934\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",71165],[[[\"\\u201c\",\"w_960\",\"w_960,w_981\",0],[\"\\u6211\",\"w_961\",\"w_961,w_982,w_983\",0],[\"\\u53bb\",\"w_962\",\"w_962,w_984,w_985\",0],[\"\\u770b\\u671b\",\"w_963\",\"w_963,w_986\",0],[\"\\u4f60\\u597d\",\"w_964\",\"w_964,w_987\",1],[\"\\u5417\",\"w_965\",\"w_965,w_966,w_988\",0],[\"\\uff1f\",\"w_966\",\"w_965,w_966,w_988\",0],[\"\\u201d\",\"w_967\",\"w_967,w_989\",0],[\"\\u2014\\u2014\",\"w_968\",\"w_968,w_990\",0],[\"\\u201c\",\"w_969\",\"w_969,w_991\",0],[\"\\u4f60\",\"w_970\",\"w_970,w_993\",0],[\"\\u5728\",\"w_971\",\"w_971,w_972,w_973,w_994\",0],[\"\\u5f00\",\"w_972\",\"w_971,w_972,w_973,w_994\",0],[\"\\u73a9\\u7b11\",\"w_973\",\"w_971,w_972,w_973,w_994\",0],[\"\\u5417\",\"w_974\",\"w_974,w_975,w_995\",0],[\"\\uff1f\",\"w_975\",\"w_974,w_975,w_995\",0],[\"\\u8def\",\"w_976\",\"w_976,w_996\",0],[\"\\u5f88\\u8fdc\",\"w_977\",\"w_977,w_998\",0],[\"\\u7684\",\"w_978\",\"w_978,w_997\",0],[\"\\u3002\",\"w_979\",\"w_979,w_999\",0],[\"\\u201d\",\"w_980\",\"w_980,w_1000\",0]],[[\"'\",\"w_981\",\"w_960,w_981\",0],[\"Shall\",\"w_982\",\"w_961,w_982,w_983\",0,\" \"],[\"I\",\"w_983\",\"w_961,w_982,w_983\",0,\" \"],[\"come\",\"w_984\",\"w_962,w_984,w_985\",0,\" \"],[\"to\",\"w_985\",\"w_962,w_984,w_985\",0,\" \"],[\"see\",\"w_986\",\"w_963,w_986\",0,\" \"],[\"you\",\"w_987\",\"w_964,w_987\",0],[\"?\",\"w_988\",\"w_965,w_966,w_988\",0],[\"'\",\"w_989\",\"w_967,w_989\",0,\" \"],[\"\\u2014\",\"w_990\",\"w_968,w_990\",0,\" \"],[\"'\",\"w_991\",\"w_969,w_991\",0],[\"Are\",\"w_992\",\"\",0,\" \"],[\"you\",\"w_993\",\"w_970,w_993\",0,\" \"],[\"kidding\",\"w_994\",\"w_971,w_972,w_973,w_994\",0],[\"?\",\"w_995\",\"w_974,w_975,w_995\",0,\" \"],[\"It\",\"w_996\",\"w_976,w_996\",0],[\"'s\",\"w_997\",\"w_978,w_997\",0,\" \"],[\"miles\",\"w_998\",\"w_977,w_998\",0],[\".\",\"w_999\",\"w_979,w_999\",0],[\"'\",\"w_1000\",\"w_980,w_1000\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",38379],[[[\"\\u201c\",\"w_1042\",\"w_1042,w_1053\",0],[\"\\u4f60\\u597d\",\"w_1043\",\"w_1043,w_1054\",1],[\"\\uff0c\",\"w_1044\",\"w_1044,w_1055\",0],[\"\\u5229\\u5179\",\"w_1045\",\"w_1045,w_1056\",0],[\"\\uff0c\",\"w_1046\",\"w_1046,w_1057\",0],[\"\\u201d\",\"w_1047\",\"w_1047,w_1058\",0],[\"\\u5979\",\"w_1048\",\"w_1048,w_1059\",0],[\"\\u817c\\u8146\",\"w_1049\",\"w_1049,w_1050,w_1061\",0],[\"\\u5730\",\"w_1050\",\"w_1049,w_1050,w_1061\",0],[\"\\u8bf4\",\"w_1051\",\"w_1051,w_1060\",0],[\"\\u3002\",\"w_1052\",\"w_1052,w_1062\",0]],[[\"'\",\"w_1053\",\"w_1042,w_1053\",0],[\"Hi\",\"w_1054\",\"w_1043,w_1054\",0],[\",\",\"w_1055\",\"w_1044,w_1055\",0,\" \"],[\"Liz\",\"w_1056\",\"w_1045,w_1056\",0],[\",\",\"w_1057\",\"w_1046,w_1057\",0],[\"'\",\"w_1058\",\"w_1047,w_1058\",0,\" \"],[\"she\",\"w_1059\",\"w_1048,w_1059\",0,\" \"],[\"said\",\"w_1060\",\"w_1051,w_1060\",0,\" \"],[\"shyly\",\"w_1061\",\"w_1049,w_1050,w_1061\",0],[\".\",\"w_1062\",\"w_1052,w_1062\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",28918],[[[\"\\u201c\",\"w_1084\",\"w_1084,w_1092\",0],[\"\\u4f60\\u597d\",\"w_1085\",\"w_1085,w_1093,w_1094\",1],[\"\\u5417\",\"w_1086\",\"w_1086,w_1095\",0],[\"\\uff0c\",\"w_1087\",\"w_1087,w_1096\",0],[\"\\u5c0f\",\"w_1088\",\"w_1088,w_1089,w_1097\",0],[\"\\u8fc8\\u514b\",\"w_1089\",\"w_1088,w_1089,w_1097\",0],[\"\\uff1f\",\"w_1090\",\"w_1090,w_1098\",0],[\"\\u201d\",\"w_1091\",\"w_1091,w_1099\",0]],[[\"'\",\"w_1092\",\"w_1084,w_1092\",0],[\"How\",\"w_1093\",\"w_1085,w_1093,w_1094\",0,\" \"],[\"are\",\"w_1094\",\"w_1085,w_1093,w_1094\",0,\" \"],[\"you\",\"w_1095\",\"w_1086,w_1095\",0],[\",\",\"w_1096\",\"w_1087,w_1096\",0,\" \"],[\"Mikey\",\"w_1097\",\"w_1088,w_1089,w_1097\",0],[\"?\",\"w_1098\",\"w_1090,w_1098\",0],[\"'\",\"w_1099\",\"w_1091,w_1099\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",124],[[[\"\\u4e54\\u6cbb\",\"w_1116\",\"w_1116,w_1149\",0],[\"\\u8bf4\",\"w_1117\",\"w_1117,w_1150\",0],[\"\\uff1a\",\"w_1118\",\"w_1118,w_1151\",0],[\"\\u201c\",\"w_1119\",\"w_1119,w_1152\",0],[\"\\u827e\\u8fbe\",\"w_1120\",\"w_1120,w_1153\",0],[\"\\uff0c\",\"w_1121\",\"w_1121,w_1154\",0],[\"\\u4f60\\u597d\",\"w_1122\",\"w_1122,w_1155,w_1156\",1],[\"\\u5417\",\"w_1123\",\"w_1123,w_1157\",0],[\"\\uff1f\",\"w_1124\",\"w_1124,w_1158\",0],[\"\\u201d\",\"w_1125\",\"w_1125,w_1159\",0],[\"\\u5979\",\"w_1126\",\"w_1126,w_1160\",0],[\"\\u76b1\",\"w_1127\",\"w_1127,w_1128,w_1161\",0],[\"\\u4e86\",\"w_1128\",\"w_1127,w_1128,w_1161\",0],[\"\\u4e00\\u4f1a\\u513f\",\"w_1129\",\"w_1129,w_1162,w_1163,w_1164\",0],[\"\\u7709\\u5934\",\"w_1130\",\"w_1130,w_1161\",0],[\"\\uff0c\",\"w_1131\",\"w_1131,w_1165\",0],[\"\\u7136\\u540e\",\"w_1132\",\"w_1132,w_1133,w_1166\",0],[\"\\u624d\",\"w_1133\",\"w_1132,w_1133,w_1166\",0],[\"\\u8ba4\\u51fa\",\"w_1134\",\"w_1134,w_1167\",0],[\"\\u4ed6\",\"w_1135\",\"w_1135,w_1179\",0],[\"\\u3002\",\"w_1136\",\"w_1136,w_1169\",0],[\"\\u201c\",\"w_1137\",\"w_1137,w_1170\",0],[\"\\u4e54\\u6cbb\\u00b7\\u5e03\\u83b1\\u514b\",\"w_1138\",\"w_1138,w_1168\",0],[\"\\uff0c\",\"w_1139\",\"w_1139,w_1169\",0],[\"\\u5662\",\"w_1140\",\"w_1140,w_1174\",0],[\"\\uff0c\",\"w_1141\",\"w_1141,w_1175\",0],[\"\\u6211\",\"w_1142\",\"w_1142,w_1176\",0],[\"\\u4e00\\u76f4\",\"w_1143\",\"w_1143,w_1144,w_1145,w_1177\",0],[\"\\u90fd\",\"w_1144\",\"w_1143,w_1144,w_1145,w_1177\",0],[\"\\u4e0d\",\"w_1145\",\"w_1143,w_1144,w_1145,w_1177\",0],[\"\\u597d\",\"w_1146\",\"w_1146\",0],[\"\\u3002\",\"w_1147\",\"w_1147,w_1178\",0],[\"\\u201d\",\"w_1148\",\"w_1148,w_1179\",0]],[[\"George\",\"w_1149\",\"w_1116,w_1149\",0,\" \"],[\"said\",\"w_1150\",\"w_1117,w_1150\",0],[\",\",\"w_1151\",\"w_1118,w_1151\",0,\" \"],[\"'\",\"w_1152\",\"w_1119,w_1152\",0],[\"Ida\",\"w_1153\",\"w_1120,w_1153\",0],[\",\",\"w_1154\",\"w_1121,w_1154\",0,\" \"],[\"how\",\"w_1155\",\"w_1122,w_1155,w_1156\",0,\" \"],[\"are\",\"w_1156\",\"w_1122,w_1155,w_1156\",0,\" \"],[\"you\",\"w_1157\",\"w_1123,w_1157\",0],[\"?\",\"w_1158\",\"w_1124,w_1158\",0],[\"'\",\"w_1159\",\"w_1125,w_1159\",0,\" \"],[\"She\",\"w_1160\",\"w_1126,w_1160\",0,\" \"],[\"frowned\",\"w_1161\",\"w_1130,w_1161\",0,\" \"],[\"for\",\"w_1162\",\"w_1129,w_1162,w_1163,w_1164\",0,\" \"],[\"a\",\"w_1163\",\"w_1129,w_1162,w_1163,w_1164\",0,\" \"],[\"moment\",\"w_1164\",\"w_1129,w_1162,w_1163,w_1164\",0,\" \"],[\"and\",\"w_1165\",\"w_1131,w_1165\",0,\" \"],[\"then\",\"w_1166\",\"w_1132,w_1133,w_1166\",0,\" \"],[\"recognition\",\"w_1167\",\"w_1134,w_1167\",0,\" \"],[\"dawned\",\"w_1168\",\"w_1138,w_1168\",0],[\".\",\"w_1169\",\"w_1139,w_1169\",0,\" \"],[\"'\",\"w_1170\",\"w_1137,w_1170\",0],[\"George\",\"w_1171\",\"\",0,\" \"],[\"Black\",\"w_1172\",\"\",0],[\".\",\"w_1173\",\"\",0,\" \"],[\"Well\",\"w_1174\",\"w_1140,w_1174\",0],[\",\",\"w_1175\",\"w_1141,w_1175\",0,\" \"],[\"I\",\"w_1176\",\"w_1142,w_1176\",0,\" \"],[\"never\",\"w_1177\",\"w_1143,w_1144,w_1145,w_1177\",0],[\".\",\"w_1178\",\"w_1147,w_1178\",0],[\"'\",\"w_1179\",\"w_1148,w_1179\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",50279],[[[\"\\u4f60\\u597d\",\"w_1244\",\"w_1244,w_1248\",1],[\"\\uff0c\",\"w_1245\",\"w_1245,w_1249\",0],[\"\\u7279\\u91cc\\u831c\",\"w_1246\",\"w_1246,w_1247,w_1250\",0],[\"\\u3002\",\"w_1247\",\"w_1246,w_1247,w_1250\",0]],[[\"Hello\",\"w_1248\",\"w_1244,w_1248\",0],[\",\",\"w_1249\",\"w_1245,w_1249\",0,\" \"],[\"Trish\",\"w_1250\",\"w_1246,w_1247,w_1250\",0]],\"\\u300a\\u67ef\\u6797\\u65af\\u9ad8\\u9636\\u82f1\\u6c49\\u53cc\\u89e3\\u5b66\\u4e60\\u8bcd\\u5178\\u300b\",28704],[[[\"\\u4f60\\u597d\",\"w_1258\",\"w_1258,w_1259,w_1266\",1],[\"\\u4e9b\",\"w_1259\",\"w_1258,w_1259,w_1266\",0],[\"\\u4e86\",\"w_1260\",\"w_1260,w_1263\",0],[\"\\u5417\",\"w_1261\",\"w_1261,w_1262,w_1267\",0],[\"\\uff1f\",\"w_1262\",\"w_1261,w_1262,w_1267\",0]],[[\"Are\",\"w_1263\",\"w_1260,w_1263\",0,\" \"],[\"you\",\"w_1264\",\"w_1261,w_1264,w_1265\",0,\" \"],[\"any\",\"w_1265\",\"w_1261,w_1264,w_1265\",0,\" \"],[\"better\",\"w_1266\",\"w_1258,w_1259,w_1266\",0],[\"?\",\"w_1267\",\"w_1261,w_1262,w_1267\",0]],\"\\u767e\\u5ea6\\u7ffb\\u8bd1\\u4f8b\\u53e5\\u5e93\",122447],[[[\"\\u4f60\\u597d\",\"w_1278\",\"w_1278,w_1294\",1],[\"\\u597d\\u770b\",\"w_1279\",\"w_1279,w_1296\",0],[\"\\u4f4f\",\"w_1280\",\"w_1280,w_1281,w_1298\",0],[\"\\u4ed6\",\"w_1281\",\"w_1280,w_1281,w_1298\",0],[\"\\uff0c\",\"w_1282\",\"w_1282,w_1299\",0],[\"\\u4e07\\u4e00\",\"w_1283\",\"w_1283,w_1300\",0],[\"\\u6709\",\"w_1284\",\"w_1284,w_1307\",0],[\"\\u4e2a\",\"w_1285\",\"w_1285,w_1295\",0],[\"\\u5dee\\u6c60\",\"w_1286\",\"w_1286,w_1296\",0],[\"\\uff0c\",\"w_1287\",\"w_1287\",0],[\"\\u4f60\",\"w_1288\",\"w_1288,w_1308\",0],[\"\\u6211\",\"w_1289\",\"w_1289,w_1301\",0],[\"\\u90fd\",\"w_1290\",\"w_1290,w_1302\",0],[\"\\u4e0d\",\"w_1291\",\"w_1291,w_1305\",0],[\"\\u597d\\u529e\",\"w_1292\",\"w_1292,w_1302,w_1303\",0],[\"\\u3002\",\"w_1293\",\"w_1293,w_1309\",0]],[[\"Keep\",\"w_1294\",\"w_1278,w_1294\",0,\" \"],[\"an\",\"w_1295\",\"w_1285,w_1295\",0,\" \"],[\"eye\",\"w_1296\",\"w_1286,w_1296\",0,\" \"],[\"on\",\"w_1297\",\"\",0,\" \"],[\"him\",\"w_1298\",\"w_1280,w_1281,w_1298\",0],[\",\",\"w_1299\",\"w_1282,w_1299\",0,\" \"],[\"because\",\"w_1300\",\"w_1283,w_1300\",0,\" \"],[\"we\",\"w_1301\",\"w_1289,w_1301\",0],[\"'ll\",\"w_1302\",\"w_1292,w_1302,w_1303\",0,\" \"],[\"get\",\"w_1303\",\"w_1292,w_1302,w_1303\",0,\" \"],[\"into\",\"w_1304\",\"\",0,\" \"],[\"trouble\",\"w_1305\",\"w_1291,w_1305\",0,\" \"],[\"if\",\"w_1306\",\"\",0,\" \"],[\"anything\",\"w_1307\",\"w_1284,w_1307\",0,\" \"],[\"happens\",\"w_1308\",\"w_1288,w_1308\",0],[\".\",\"w_1309\",\"w_1293,w_1309\",0]],\"\\u767e\\u5ea6\\u7ffb\\u8bd1\\u4f8b\\u53e5\\u5e93\",126272],[[[\"\\u4f60\\u597d\",\"w_1342\",\"w_1342,w_1343,w_1344,w_1347,w_1348\",1],[\"\\u597d\\u513f\",\"w_1343\",\"w_1342,w_1343,w_1344,w_1347,w_1348\",0],[\"\\u60f3\\u60f3\",\"w_1344\",\"w_1342,w_1343,w_1344,w_1347,w_1348\",0],[\"\\u5427\",\"w_1345\",\"w_1345,w_1349,w_1350\",0],[\"\\uff01\",\"w_1346\",\"w_1346,w_1351\",0]],[[\"Just\",\"w_1347\",\"w_1342,w_1343,w_1344,w_1347,w_1348\",0,\" \"],[\"think\",\"w_1348\",\"w_1342,w_1343,w_1344,w_1347,w_1348\",0,\" \"],[\"it\",\"w_1349\",\"w_1345,w_1349,w_1350\",0,\" \"],[\"over\",\"w_1350\",\"w_1345,w_1349,w_1350\",0],[\".\",\"w_1351\",\"w_1346,w_1351\",0]],\"\\u767e\\u5ea6\\u7ffb\\u8bd1\\u4f8b\\u53e5\\u5e93\",121745]]","tag":["hello","hi"],"single":""},"logid":4175239806}
    複製程式碼

    由此推斷出該請求是真正進行翻譯的請求。

1.2 分析傳送翻譯請求的引數

  • 請求的引數資訊

    • from:需要翻譯的語言型別
    • to: 需要翻譯成哪種語言
    • query:需要翻譯的內容
    • transtype:不清楚,但是這個值一直不變
    • simple_means_flag: 不清楚,但是這個值一直不變
    • sign:經過加密處理後的結果,不同的內容不一樣
    • token:也沒有發生變化
  • 需要處理的引數

    • sign 引數需要我們去分析是怎麼生成的,在開發者模式下搜尋 sign 發現結果過多,所以搜尋 simple_means_flag 來找到 sign

      search

    • 通過圖示操作找到對應的檔案,如圖所示,發現格式很亂,點選左下角 {} 來格式化程式碼。

      format

    • 格式完程式碼完後發現 sign 引數是通過呼叫 m() 函式並傳入需要翻譯的內容處理生成的。 token 是通過 window.common.token獲取的,在 console 下執行該語句,就能得到值。那麼在 html 頁面中搜尋 token,就能獲取該值。可以通過正則在匹配到。

      js

    console

    • 尋找 m() 函式。在格式完後的js中直接搜尋 m 會有很多匹配結果,找起來很費勁,猜測應該是將一個函式命名為 m。發現傳送翻譯請求的函式在如下所示的大函式中。

      define("translation:widget/translate/input/translate", function(t, a) {
      "use strict";
      var e = t("translation:widget/translate/input/prompt")
        , n = t("translation:widget/translate/input/textarea")
        , r = t("translation:widget/common/util")
        , s = t("translation:widget/translate/output/output")
        , o = t("translation:widget/common/config/trans")
        , i = t("translation:widget/translate/input/processlang")
        , l = t("translation:widget/common/string")
        , u = t("translation:widget/translate/input/soundicon")
        , g = t("translation:widget/translate/input/hash")
        , c = t("translation:widget/common/environment")
        , d = t("translation:widget/translate/input/longtext")
        , p = t("translation:widget/common/sendLog")
        , y = t("translation:widget/translate/details/dictionary/simplemeans")
        , f = t("translation:widget/translate/history/history")
        , m = t("translation:widget/translate/input/pGrab")
        , h = t("translation:widget/translate/details/adLink/adLink")
        , w = {
          onTrans: function(t) {
              y.translateStopRepeat() || y.shutdownAudio();
              var a = (n.getElem(),
              n.getVal())
                , e = this
                , s = t && t.transtype;
              if (r.isUrl(a))
                  return void this.translateWebPage(a);
              if (a.length > 0 && p.sendIndexDisplayLog({
                  action: "query"
              }),
              this.isQueryValid(a)) {
                  var o = a;
                  o.length > 50 && (o = l.cutByByte(o, 0, 50).replace(/[\uD800-\uDBFF]$/, ""));
                  var i = {
                      query: o
                  };
                  $.ajax({
                      url: "/langdetect",
                      type: "POST",
                      data: i,
                      success: function(t) {
                          0 === t.error && t.lan ? e.langIsDeteced(t.lan, a, s) : e.reponseQuery(a)
                      }
                  })
              }
          },
          isQueryValid: function(t) {
              return t ? !0 : !1
          },
          processQuery: function(t) {
              var a = t;
              if (l.getByte(t) > o.MAX_QUERY_COUNT) {
                  c.set("needLongtextTip", !0);
                  var e = t;
                  a = l.cutByByte(t, 0, o.MAX_QUERY_COUNT).replace(/[\uD800-\uDBFF]$/, ""),
                  e = l.cutByByte(e, o.MAX_QUERY_COUNT, o.MAX_QUERY_COUNT + 9),
                  d.showTip({
                      query: e
                  })
              }
              return a
          },
          langIsDeteced: function(t, a, n, r) {
              if (null !== t) {
                  var s = $(".select-from-language .language-selected").attr("data-lang")
                    , o = $(".select-to-language .language-selected").attr("data-lang")
                    , l = !1;
                  c.get("langChangedByUser") && t === o && (l = !0);
                  var g = null;
                  r && !c.get("fromLangIsAuto") && s !== t ? g = i.processOcrLang(t, s, o) : (e.show(t, s),
                  g = i.getLang(t, s, o)),
                  u.show();
                  var d = this
                    , a = this.processQuery(a)
                    , p = {
                      from: g.fromLang,
                      to: g.toLang,
                      query: a,
                      transtype: n,
                      simple_means_flag: 3,
                      sign: m(a),
                      token: window.common.token
                  };
                  this.translateXHR && 4 !== this.translateXHR.readyState && this.translateXHR.abort(),
                  this.translateXHR = $.ajax({
                      type: "POST",
                      url: "/v2transapi",
                      cache: !1,
                      data: p
                  }).done(function(t) {
                      c.set("isInRtTransState", !0),
                      d.translateSuccess(t, g.fromLang, g.toLang, a, l)
                  })
              }
          },
          translateWebPage: function(t) {
              var a = "/";
              "https:" === location.protocol && (a = "http://fanyi.baidu.com/"),
              document.location.href = [a + "transpage?", "query=" + encodeURIComponent(t), "&source=url", "&ie=utf8", "&from=" + $(".select-from-language .language-selected").attr("data-lang"), "&to=" + $(".select-to-language .language-selected").attr("data-lang"), "&render=1"].join("")
          },
          textareaFocus: function() {
              n.focus()
          },
          translateSuccess: function(t, a, e, r, i) {
              return n.getVal() ? (r && encodeURIComponent(r).length < o.MAX_URL_COUNT && f.add(a, e, $.trim(r)),
              f.hideHistory(),
              h.hide(),
              s.checkResponse({
                  res: t,
                  from: a,
                  to: e,
                  query: r,
                  badCaseByForce: i
              }),
              void g.setHash({
                  query: r
              })) : void c.set("isInRtTransState", !1)
          },
          reponseQuery: function() {}
      };
      a.onTranslate = function(t) {
          w.onTrans(t)
      }
      ,
      a.translateAfterOcr = function(t, a) {
          _hmt.push(["_trackEvent", "首頁", "59_首頁頁面_翻譯query量_圖片"]),
          w.langIsDeteced(t, a, void 0, !0)
      }
      });
      複製程式碼

      m

      這個大函式中有個 m 函式,搜尋 m 對應的 translation:widget/translate/input/pGrab, 發現此段程式碼中有一行為

      return p = n(p, D),p ^= s,0 > p && (p = (2147483647 & p) + 2147483648),p %= 1e6,p.toString() + "." + (p ^ m)
      複製程式碼

      其中p.toString() + "." + (p ^ m) 正好與 sign 的格式相符,所以推測通過這個函式來生成sign,我們在python中呼叫 execjs 執行這個函式就能得到 sign 值。

    • m 函式的程式碼

      define("translation:widget/translate/input/pGrab", function(r, o, t) {
      "use strict";
      function a(r) {
          if (Array.isArray(r)) {
              for (var o = 0, t = Array(r.length); o < r.length; o++)
                  t[o] = r[o];
              return t
          }
          return Array.from(r)
      }
      function n(r, o) {
          for (var t = 0; t < o.length - 2; t += 3) {
              var a = o.charAt(t + 2);
              a = a >= "a" ? a.charCodeAt(0) - 87 : Number(a),
              a = "+" === o.charAt(t + 1) ? r >>> a : r << a,
              r = "+" === o.charAt(t) ? r + a & 4294967295 : r ^ a
          }
          return r
      }
      function e(r) {
          var o = r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g);
          if (null === o) {
              var t = r.length;
              t > 30 && (r = "" + r.substr(0, 10) + r.substr(Math.floor(t / 2) - 5, 10) + r.substr(-10, 10))
          } else {
              for (var e = r.split(/[\uD800-\uDBFF][\uDC00-\uDFFF]/), C = 0, h = e.length, f = []; h > C; C++)
                  "" !== e[C] && f.push.apply(f, a(e[C].split(""))),
                  C !== h - 1 && f.push(o[C]);
              var g = f.length;
              g > 30 && (r = f.slice(0, 10).join("") + f.slice(Math.floor(g / 2) - 5, Math.floor(g / 2) + 5).join("") + f.slice(-10).join(""))
          }
          var u = void 0
            , l = "" + String.fromCharCode(103) + String.fromCharCode(116) + String.fromCharCode(107);
          u = null !== i ? i : (i = window[l] || "") || "";
          for (var d = u.split("."), m = Number(d[0]) || 0, s = Number(d[1]) || 0, S = [], c = 0, v = 0; v < r.length; v++) {
              var A = r.charCodeAt(v);
              128 > A ? S[c++] = A : (2048 > A ? S[c++] = A >> 6 | 192 : (55296 === (64512 & A) && v + 1 < r.length && 56320 === (64512 & r.charCodeAt(v + 1)) ? (A = 65536 + ((1023 & A) << 10) + (1023 & r.charCodeAt(++v)),
              S[c++] = A >> 18 | 240,
              S[c++] = A >> 12 & 63 | 128) : S[c++] = A >> 12 | 224,
              S[c++] = A >> 6 & 63 | 128),
              S[c++] = 63 & A | 128)
          }
          for (var p = m, F = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(97) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(54)), D = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(51) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(98)) + ("" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(102)), b = 0; b < S.length; b++)
              p += S[b],
              p = n(p, F);
          return p = n(p, D),
          p ^= s,
          0 > p && (p = (2147483647 & p) + 2147483648),
          p %= 1e6,
          p.toString() + "." + (p ^ m)
      }
       var i = null;
       t.exports = e
      })
      複製程式碼

      函式中有兩行程式碼為:

      l = "" + String.fromCharCode(103) + String.fromCharCode(116) + String.fromCharCode(107);
      u = null !== i ? i : (i = window[l] || "") || "";
      複製程式碼

      在 console 下執行第一行得到 l 為 gtk,再執行 window["gtk"], 得到 gtk 的值,在 html 中也能搜到。需要用到這個值,所以像token一樣用正則匹配即可獲得

    • 修改js函式

      經過除錯修改,js修改為

      var i = null
      function a(r) {
          if (Array.isArray(r)) {
              for (var o = 0, t = Array(r.length); o < r.length; o++)
                  t[o] = r[o];
              return t
          }
          return Array.from(r)
      }
      function n(r, o) {
          for (var t = 0; t < o.length - 2; t += 3) {
              var a = o.charAt(t + 2);
              a = a >= "a" ? a.charCodeAt(0) - 87 : Number(a),
              a = "+" === o.charAt(t + 1) ? r >>> a : r << a,
              r = "+" === o.charAt(t) ? r + a & 4294967295 : r ^ a
          }
          return r
      }
      function e(r, gtk) {
          var t = r.length;
          t > 30 && (r = "" + r.substr(0, 10) + r.substr(Math.floor(t / 2) - 5, 10) + r.substr(-10, 10));
          var u = void 0,
          u = null !== i ? i : (i = gtk || "") || "";
          for (var d = u.split("."), m = Number(d[0]) || 0, s = Number(d[1]) || 0, S = [], c = 0, v = 0; v < r.length; v++) {
              var A = r.charCodeAt(v);
              128 > A ? S[c++] = A : (2048 > A ? S[c++] = A >> 6 | 192 : (55296 === (64512 & A) && v + 1 < r.length && 56320 === (64512 & r.charCodeAt(v + 1)) ? (A = 65536 + ((1023 & A) << 10) + (1023 & r.charCodeAt(++v)),
              S[c++] = A >> 18 | 240,
              S[c++] = A >> 12 & 63 | 128) : S[c++] = A >> 12 | 224,
              S[c++] = A >> 6 & 63 | 128),
              S[c++] = 63 & A | 128)
          }
          for (var p = m, F = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(97) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(54)), D = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(51) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(98)) + ("" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(102)), b = 0; b < S.length; b++)
              p += S[b],
              p = n(p, F);
          return p = n(p, D),
          p ^= s,
          0 > p && (p = (2147483647 & p) + 2147483648),
          p %= 1e6,
          p.toString() + "." + (p ^ m)
      }
      複製程式碼

2. 程式碼示例

import requests
import json
import re
import execjs
import sys

class BaiduTranslation(object):
    def __init__(self, content):
        self.headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
            'Cookie': 'BIDUPSID=E9B058D087F0C0FDD3A0C88A93681FCE; PSTM=1536569393; BDUSS=zFYV1NpRVRmSDhEVWg2Y3pjS2t5RFdXWGFoa0NIeFROdnozdWRkWU1MZHB2T3RiQVFBQUFBJCQAAAAAAAAAAAEAAADnj6yvtdK~y83GtuA5NQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGkvxFtpL8RbM; MCITY=-%3A; BAIDUID=0A5182736E61ACA3D7442FC0DDE62F01:FG=1; BDSFRCVID=bV4sJeCCxG3J_p59aEDMQwqW21UdQvfiKQYI3J; H_BDCLCKID_SF=JRA8oK05JIvhDRTvhCcjh-FSMgTBKI62aKDsKp7g-hcqEIL4LPRbQR0pjnOJBnOfQmTH2DQma4OkHUbSj4Qoj-6QbfvLBTolLeJMXJRttq5nhMJm257JDMP0qJ7jttTy523ibR6vQpnNqxtuj6tWj6j0DNR22Pc22-oKWnTXbRu_Hn7zeUjoDbtpbtbmhU-eyJni_C3m5tnnHlQPQJosbR8h5qLDLROg0R7ZVDD5fCtbMDLr-Pvo5t3H5MoX5-QXbPo2WbC35tooDtOv5J5jbjus5p62-KCHtbP8_KL8tD8MbD0Cq6K5j5cWjG4OexneWDTm5-nTtK3VjP_63-jS3pby0M5O2-rLJaKtbM8baU85OCFlD5thD63BeaRKeJQX2COXsJ6VHJOoDDkRjMR5y4LdLp7xJhT00bFf0bRmL-TdO56CbMFMjl4JyM7EtMCeWJLe_KDaJItWbP5kMtn_qttjMfbWetTbHD7yWCv5Wt55OR5JLn7nDpIX0a-fK-7wK66L0lo_2hO1MljhW55SMfJyyGCHt6tjtnAj_Iv55RTWjJuk-4r_bnIJMqJ-2tvtK4o2WbCQJhu28pcNLTDKjbIHLfcaqlkLBK5f-l5-Bt0B8prhjpO1j4_eKG8OttQL3b63blrSt-5J8h5jDh3qb6ksD-RC5JTwJjvy0hvcLR6cShnq5fjrDRLbXU6BK5vPbNcZ0l8K3l02VKO_e6t5jjJLDGtsKbQKaDQ036rh-6rjDnCr2MnOXUI8LNDH2x4HXKTBVlv8LKJbSq54X6rCbbk80RO7ttoAKa535hTR3UjAEf5lqf7nDUL1Db3DW6vMtg3tsRngfInoepvo0tcc3MkF5tjdJJQOBKQB0KnGbUQkeq8CQft205tpeGLfq6tOfnksL6rJbPoEq5rnhPF3-l53KP6-3MJO3b7ZM-tafRjpsh6h5nQRD6_AbbQqKtciLG5AohFLK-oj-D_mD5AB3J; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; H_PS_PSSID=28312_1456_21125_28132_28266_22160; delPer=0; PSINO=2; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0; locale=zh; from_lang_often=%5B%7B%22value%22%3A%22en%22%2C%22text%22%3A%22%u82F1%u8BED%22%7D%2C%7B%22value%22%3A%22zh%22%2C%22text%22%3A%22%u4E2D%u6587%22%7D%5D; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1547433565; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1547433565; to_lang_often=%5B%7B%22value%22%3A%22zh%22%2C%22text%22%3A%22%u4E2D%u6587%22%7D%2C%7B%22value%22%3A%22en%22%2C%22text%22%3A%22%u82F1%u8BED%22%7D%5D',
            'Host': 'fanyi.baidu.com',
            'Origin': 'https: // fanyi.baidu.com',
            'Referer': 'https: // fanyi.baidu.com /?aldtype = 16047'
        }
        self.detect_url = 'https://fanyi.baidu.com/langdetect'
        self.trans_url = 'https://fanyi.baidu.com/v2transapi'
        self.ori_url = 'https://fanyi.baidu.com/'
        self.content = content
        self.session = requests.Session()
        self.token = ''
        self.gtk = ''

    def get_token_gtk(self):
        response = self.session.get(self.ori_url, headers=self.headers)
        html = response.content.decode()
        token_matches = re.findall("token: '(.*?)'", html, re.S)
        for match in token_matches:
            self.token = match
        gtk_matches = re.findall("window.gtk = '(.*?)';", html, re.S)
        for match in gtk_matches:
            self.gtk = match
        # print(self.token, self.gtk)

    def get_lan_type(self):
        lan_params = {
            'query': self.content
        }
        response = self.session.post(self.detect_url, headers=self.headers, data=lan_params)
        data = json.loads(response.content.decode())
        return data['lan']

    def get_sign(self):
        js = """
            var i = null
            function a(r) {
                if (Array.isArray(r)) {
                    for (var o = 0, t = Array(r.length); o < r.length; o++)
                        t[o] = r[o];
                    return t
                }
                return Array.from(r)
            }
            function n(r, o) {
                for (var t = 0; t < o.length - 2; t += 3) {
                    var a = o.charAt(t + 2);
                    a = a >= "a" ? a.charCodeAt(0) - 87 : Number(a),
                    a = "+" === o.charAt(t + 1) ? r >>> a : r << a,
                    r = "+" === o.charAt(t) ? r + a & 4294967295 : r ^ a
                }
                return r
            }
            function e(r, gtk) {
                var t = r.length;
                t > 30 && (r = "" + r.substr(0, 10) + r.substr(Math.floor(t / 2) - 5, 10) + r.substr(-10, 10));
                var u = void 0,
                u = null !== i ? i : (i = gtk || "") || "";
                for (var d = u.split("."), m = Number(d[0]) || 0, s = Number(d[1]) || 0, S = [], c = 0, v = 0; v < r.length; v++) {
                    var A = r.charCodeAt(v);
                    128 > A ? S[c++] = A : (2048 > A ? S[c++] = A >> 6 | 192 : (55296 === (64512 & A) && v + 1 < r.length && 56320 === (64512 & r.charCodeAt(v + 1)) ? (A = 65536 + ((1023 & A) << 10) + (1023 & r.charCodeAt(++v)),
                    S[c++] = A >> 18 | 240,
                    S[c++] = A >> 12 & 63 | 128) : S[c++] = A >> 12 | 224,
                    S[c++] = A >> 6 & 63 | 128),
                    S[c++] = 63 & A | 128)
                }
                for (var p = m, F = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(97) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(54)), D = "" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(51) + ("" + String.fromCharCode(94) + String.fromCharCode(43) + String.fromCharCode(98)) + ("" + String.fromCharCode(43) + String.fromCharCode(45) + String.fromCharCode(102)), b = 0; b < S.length; b++)
                    p += S[b],
                    p = n(p, F);
                return p = n(p, D),
                p ^= s,
                0 > p && (p = (2147483647 & p) + 2147483648),
                p %= 1e6,
                p.toString() + "." + (p ^ m)
            }
        """
        sign = execjs.compile(js).call('e', self.content, self.gtk)
        return sign

    def get_trans(self):
        # 1. 獲取 token 和 gtk
        self.get_token_gtk()
        # 2. 獲取 sign
        sign = self.get_sign()
        # 3. 獲取語言型別
        lan_type = self.get_lan_type()
        if lan_type == 'zh':
            from_lan = 'zh'
            to_lan = 'en'
        else:
            from_lan = 'en'
            to_lan = 'zh'
        # 傳送翻譯請求
        params = {
            'from': from_lan,
            'to': to_lan,
            'query': self.content,
            'transtype': 'realtime',
            'simple_means_flag': 3,
            'sign': sign,
            'token': self.token
        }
        response = self.session.post(self.trans_url, headers=self.headers, data=params)
        # print(response.request.headers)
        # print(response.content.decode())
        data = json.loads(response.content.decode())
        result = data['trans_result']['data'][0]['dst']
        print('翻譯結果: ' + result)
        
if __name__ == '__main__':
    trans_str = sys.argv[1]
    trans = BaiduTranslation(trans_str)
    trans.get_trans()
複製程式碼

在 cmd 下執行結果:

結果

github連結: github.com/einherjarCa…

相關文章