import requests import re while 1 < 10: f = 0 url = "https://fanyi.baidu.com/sug" a = input("请输入要翻译的单词或句子:") head = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.55" } dat = { "kw":a } b = requests.post(url,data=dat,headers = head) c = b.json() d = c['data'] e = len(d) r = re.compile("{'k': '(?P<yc>.*?)', 'v': '(?P<fy>.*?)'}",re.S) while f < e: n = f + 1 h = str(d[f]) l = r.finditer(h) for m in l: print(str(n) + ". 原词: " + m.group("yc") + " 翻译 : " + m.group("fy")) f = f+1 b.close()
python教程
python百度翻译爬虫
python教程
51源码
2022-11-02
共人阅读
下一篇: 返回列表
热门推荐
-
01百度图库python批量爬取下载代码 2
-
02Python爬取wallhaven壁纸脚本 2
-
03Python自动爬取轻壁纸网站脚本 2
-
04Python批量抓取公众号,下载音频和视频 2
-
05利用Python开发个简单版的磁力搜索工具源码 0