js 访问 URL 链接

直接上代码

var url = "https://www.cnblogs.com/xuchunlin/p/14848864.html"

var time = 10000;
var timeout = false;
var request = new XMLHttpRequest();
var timer = setTimeout(function() {
    timeout = true;
    request.abort();
}, time);

request.open("GET", url);
request.onreadystatechange = function() {

    if (request.status === 200) {
        // 打印出网页结果
        console.log(request.responseText);

    }

}
;

request.send(null);

  

posted @ 2021-06-28 17:14  淋哥  阅读(2760)  评论(0编辑  收藏  举报