jquery獲取文檔的或某個元素的html 閑的沒事湊活事的教學
// 獲取文檔的
// 這個是獲取本文檔可能被擴展插件和廣告屏蔽器污染的html
$(":root").prop("outerHTML");
// 利用promise異步獲取未被污染的文檔
// 我這么寫是為了方便用await優雅的寫代碼,用fetch也行
await new Promise(function (reslove) {
$.get(location.href, function (data) {
reslove(data);
});
});
// ??,這就是更優雅的用fetch寫的獲取
await fetch(location.href).then(res => res.text())
// 獲取元素的
// 也只有這一種方式
$(ele).prop("outerHTML");
啊啊啊,好水啊,寒假好無聊啊
哦吼吼,能看到這個鏈接就說明我的文章被爬蟲爬了
請尊重原作者: http://www.rzrgm.cn/dffxd/
請尊重原作者: http://www.rzrgm.cn/dffxd/
本文來自博客園,作者:月神的使者,轉載請注明原文鏈接:http://www.rzrgm.cn/dffxd/p/17069414.html

浙公網安備 33010602011771號