今天在微信官方社区看到一篇微信公众号文章防盗检测的文章。是的,就是在微信官方社区,呃呃呃,这波有点子秀。
上代码:
getUrl(URL){
//url 为微信公众号文章链接
let http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
let realurl = http + '//cors-anywhere.herokuapp.com/' + URL;
axios.get(realurl).then((response)=>{
console.log(response)
let html = response.data;
html = html.replace(/data-src/g, "src")
.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/g, '')
.replace(/https/g,'http');
let html_src = 'data:text/html;charset=utf-8,' + html;
let iframe = document.getElementById('iFrame');
iframe.src = html_src;
},(err)=>{console.log(err);});
赶紧码住,以防明天就没了。
附上原文链接:https://cloud.tencent.com/developer/article/1408176