最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Mac中Chrome抓包分析google翻译请求的参数和逻辑

Mac crifan 3596浏览 0评论
折腾:
【未解决】Python中寻找和使用在线翻译服务翻译中文为英文
期间,去mac中抓包分析一下google翻译的逻辑。
Google 翻译
此处,需要抓包模拟请求和提取结果
以及期间还要用上此处的本地的ssr的代理,否则不翻墙没法访问
抓包到请求了:
https://translate.google.cn/translate_a/single?client=webapp&sl=zh-CN&tl=en&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&pc=1&otf=1&ssel=0&tsel=0&kc=1&tk=73822.494967&q=%E8%A3%85%E4%BF%AE%20PVC%20%E5%AE%B6%E7%94%A8%20%E6%A9%A1%E8%83%B6%E5%9C%B0%E6%9D%BF%20%E5%9C%B0%E6%9D%BF%E9%9D%A9


Response:
[[["Decoration PVC Household Rubber Floor Floor Leather","装修 PVC 家用 橡胶地板 地板革",null,null,3,null,null,null,[[["2d872eccc9e3cd77b6198222b546ff3f","zh_en_2019q4.md"]
]
]
]
,[null,null,null,"Zhuāngxiū PVC jiāyòng xiàngjiāo dìbǎn dìbǎn gé"]
]
,null,"zh-CN",null,null,[["装修 PVC 家用 橡胶地板 地板革",null,[["Decoration PVC Household Rubber Floor Floor Leather",0,true,false]
,["Home decoration PVC rubber flooring vinyl flooring",0,true,false]
]
,[[0,18]
]
,"装修 PVC 家用 橡胶地板 地板革",0,0]
]
,1.0,null,[["zh-CN"]
,null,[1.0]
,["zh-CN"]
]
]
返回的json格式化:
JSON-handle
VSCode:
拷贝出更多细节请求的参数
Copy->Copy as cURL
cCURL:
curl 'https://translate.google.cn/translate_a/single?client=webapp&sl=zh-CN&tl=en&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&pc=1&otf=1&ssel=0&tsel=0&kc=1&tk=73822.494967&q=%E8%A3%85%E4%BF%AE%20PVC%20%E5%AE%B6%E7%94%A8%20%E6%A9%A1%E8%83%B6%E5%9C%B0%E6%9D%BF%20%E5%9C%B0%E6%9D%BF%E9%9D%A9' -H 'authority: translate.google.cn' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36' -H 'accept: */*' -H 'x-client-data: CIe2yQEIo7bJAQjEtskBCKmdygEI4qjKAQjOsMoBCOexygEI6rHKAQj3tMoBGKukygE=' -H 'sec-fetch-site: same-origin' -H 'sec-fetch-mode: cors' -H 'referer: https://translate.google.cn/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8' -H 'cookie: _ga=GA1.3.619751010.1575119897; _gid=GA1.3.799863750.1575119897; NID=192=N7fxJ8LApFBszOLzedeuVrgaq9mE_S-JUGp7nNLfQPgCsT7AtdI0kDLq9yI13q1qhjm8lsJDMgFfHyJkmRzIRaeHagqVRswivp3Ux_UYySIZlLlbkhNfZkZZJmZNHQP7NwEUVbJ7Wyzs6x85UEsF7ypDqmbCMbS9c4_JF3nyVD4; 1P_JAR=2019-12-1-1' --compressed
然后去尝试写代码模拟,看看能否获取到翻译结果
对于请求的url:
https://translate.google.cn/translate_a/single?client=webapp&sl=zh-CN&tl=en&hl=zh-CN&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&pc=1&otf=1&ssel=0&tsel=0&kc=1&tk=73822.494967&q=%E8%A3%85%E4%BF%AE%20PVC%20%E5%AE%B6%E7%94%A8%20%E6%A9%A1%E8%83%B6%E5%9C%B0%E6%9D%BF%20%E5%9C%B0%E6%9D%BF%E9%9D%A9
用postman去帮忙分割参数:
看起来参数是:
  • 核心参数
    • sl=zh-CN
      • sl估计是source language
    • tl=en
      • tl估计是 translate/translated language
    • q=%E8%A3%85%E4%BF%AE%20PVC%20%E5%AE%B6%E7%94%A8%20%E6%A9%A1%E8%83%B6%E5%9C%B0%E6%9D%BF%20%E5%9C%B0%E6%9D%BF%E9%9D%A9
  • 其他参数
    • client=webapp
    • hl=zh-CN
      • human language?
      • 不知道是否需要
    • pc=1
    • otf=1
关于:
%E8%A3%85%E4%BF%AE%20PVC%20%E5%AE%B6%E7%94%A8%20%E6%A9%A1%E8%83%B6%E5%9C%B0%E6%9D%BF%20%E5%9C%B0%E6%9D%BF%E9%9D%A9
估计是原始中文的utf-8编码
后来发现不是
utf-8解码
而是url解码
在线url网址编码、解码-BeJSON.com
https://www.bejson.com/enc/urlencode/

转载请注明:在路上 » 【已解决】Mac中Chrome抓包分析google翻译请求的参数和逻辑

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.188 seconds, using 22.15MB memory