扫码关注官方订阅号
比如在谷歌打开贴吧网页后,在控制台输入 fetch('http://tieba.baidu.com').then(res=>res.text()).then(html=>console.log(html)),因为贴吧用的是gbk编码,fetch出来的结果乱码了,怎么解决?谢谢!!!
闭关修行中......
fetch('http://tieba.baidu.com') .then(res=> res.blob()) .then(blob => { var reader = new FileReader(); reader.onload = function(e) { var text = reader.result; console.log(text) } reader.readAsText(blob, 'GBK') })
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
闭关修行中......