当前位置:   article > 正文

百度翻译Python-Post抓包使用代码_百度翻译汉字抓包

百度翻译汉字抓包
# coding=utf-8

import urllib.request
import urllib.parse

post_url = 'https://fanyi.baidu.com/v2transapi'
# word = input('请输入您要搜索的单词:')
# 'sign': '275695.55262',
# 'token': '7f0ccf4952ab4548d8862aa40b5e37d9',
# 以上两个参数需要读懂代码进行破解
formdata = {
    'sign': '275695.55262',
    'simple_means_flag': '3',
    'token': '7f0ccf4952ab4548d8862aa40b5e37d9',
    'from': 'en',
    'transtype': 'realtime',
    'query': 'wolf',
    'to': 'zh',
}

headers = {
    'Host': 'fanyi.baidu.com',
    # 'Connection': 'keep-alive',
    # 'Content-Length': '120',
    # 'Accept': '*/*',
    'Origin': 'https://fanyi.baidu.com',
    'X-Requested-With': 'XMLHttpRequest',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64)'
                  ' AppleWebKit/537.36 (KHTML, like Gecko)'
                  ' Chrome/70.0.3538.67 Safari/537.36',
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'Referer': 'https://fanyi.baidu.com/?aldtype=85',
    # 'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cookie': 'BAIDUID=E65A26ACA8F1B594CF1A012F889863E1:FG=1; '
              'BIDUPSID=E65A26ACA8F1B594CF1A012F889863E1; '
              'PSTM=1546947993; '
              'locale=zh;'
              ' to_lang_often=%5B%7B%22value%22%3A%22'
              'en%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;'
              ' from_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;'
              ' BDORZ=FFFB88E999055A3F8A630C64834BD6D0; '
              'BDRCVFR[mkUqnUt8juD]=aeXf-1x8UdYcs; '
              'delPer=0; H_PS_PSSID=1431_27210_21105_28329_28132_28267;'
              ' PSINO=2; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1547920390,1547996722; '
              'Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1547996722',
}

request = urllib.request.Request(url=post_url, headers=headers)
formdata = urllib.parse.urlencode(formdata).encode()
response = urllib.request.urlopen(request, formdata)
print(response.read().decode())

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55

百度翻译经过更新之后已经不能够简单的进行破解了,但是仔细阅读上述代码还是可以进行抓包使用的,如果想要扩展到所有内容的翻译上面,需要仔细抓包在JavaScript包中找到关键的两个参数进行分析和破解!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/352893
推荐阅读
相关标签
  

闽ICP备14008679号