Dmi*_*iev 3 audio google-chrome
Bunenas tardes se\xc3\xb1ores!
\n多年来,我通过 Chrome DevTools 和 Network 选项卡从 google.translate.com 中提取声音。单击网络选项卡中的声音按钮时,会出现 mp3 文件。我只需单击它并下载以用于进一步的教育目的。
\n现在(字面上的今天)只有 XHR 类型的文件,在方括号内有无数的字符序列,就像 JS 数组中的字符串一样。而且页面本身相当复杂。
\n如何在新的环境下提取声音?
\n谢谢。
\n小智 5
php 代码执行此操作:
<?php
$lang = 'en';
$text = 'hello world';
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://translate.google.com/_/TranslateWebserverUi/data/batchexecute',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => http_build_query([
'f.req' => json_encode([
[
[
'jQ1olc',
json_encode([
$text,
$lang,
null,
json_encode(null),
]),
null,
'generic',
]
]
]),
]),
]);
$response = curl_exec($curl);
curl_close($curl);
if ($response && preg_match('#//NE[^\\\\]+#', $response, $matches)) {
file_put_contents('test.mp3', base64_decode($matches[0]));
}
else {
echo "error\n";
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4351 次 |
最近记录: |