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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
import requests
import urllib
import re
import time
def get_data(text):
json = {
"qd": "110774",
"ver": "010178",
"zbid": "4b1ab4d1db435532",
"text": text,
"speed": 0,
"pitch": 0,
"volume": 95,
"isurl": 2,
"viptype": "0",
"bgdelaytime": 0,
"textdelaytime": 0,
"bgvolume": 20,
"emotion": "",
"emotiondegree": 50,
"opertype": "1001"
}
str_json=str(json).replace('\'','\"')
info = urllib.parse.quote(str_json)
data = "req=" + info
return data
def get_json(data):
url = "" ##接口就不放了。。。
headers = {
"Referer": "https://servicewechat.com/wx976547f8ab927081/6/page-frame.html",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 "
"Safari/537.36 MicroMessenger/7.0.9.501 NetType/WIFI MiniProgramEnv/Windows WindowsWechat",
"Host": "pysq.shipook.com",
"Cookie": "SESSION=YTcyNmU3NmYtZmNkYy00N2IwLTg3YzEtMGRlZWQxMTZlMjUy",
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "text/html, application/xhtml+xml, */*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-cn",
"Cache-Control": "no-cache",
"Connection": "Keep-Alive",
"Content-Length": "401",
}
res = requests.post(url, headers=headers, data=data, verify=False).text
url = re.findall('"audiourl":"(.*?)"',res)[0]
# print(url)
return url
def down_url(url):
headers ={"User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, "
"like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"}
res = requests.get(url,headers=headers).content
with open(".mp3",'ab') as f:
f.write(res)
print("在当前目录下已经下载成功!")
if __name__ == '__main__':
text = input("请输入你想转成语音的文字,按回车结束:\n")
print("==================")
print(text)
print("==================")
print("马上就好,请等待下载。。。。")
time.sleep(3)
data = get_data(text)
url = get_json(data)
down_url(url)
|