我想從網(wǎng)頁(yè)中取得innerHTML。它在頁(yè)面 html 文件的正文內(nèi)容中使用 iframe。
這是我正在使用的程式碼,但似乎沒(méi)有發(fā)生任何事情。我也知道它們一定是我這裡的程式碼中的一些問(wèn)題,這就是為什麼它不能正常工作的原因。
document.querySelectorAll('"body > iframe"')[0].innerHTML;
到目前為止我已經(jīng)嘗試過(guò)這一點(diǎn),並且我正在網(wǎng)上查找是否可以以某種方式使其工作。
這是從瀏覽器偵錯(cuò)器工具中手動(dòng)提取的程式碼的 html 部分。
<body><div id="__next"><div id="main" class="jsx-834240835 desktop-container"><div class="jsx-1905932170 header-><div class="jsx-1905932170 header-&container white "><div class="jsx-1905932170 header-content"><div class="jsx-1905932170 hamburger-wrapper"><a ><a title="TikTok" class="jsx-3359950850 logo-link">/div><iframe src="https://www.tiktok.com/creator#/upload?lang=en /" style="height: 650px; border-style: none; width: 100%; margin-bottom: -6px;"></iframe><div style="visibility: hidden; position: absolute; bot : 0px; left: 0px; right: 0px; height: 356px; z-index: -1;"></div><div id="creator-center-footer"><div class=" jsx-3176438893 footer-container"><footer class="jsx-3176438893 footer-content-wrapper"><div class="jsx-3176438893 tiapper-log;<div class="jsx-31,9858893 ti logo-container jsx-997609344"><img src="https://lf16-tiktok-web.ttwstatic.com/obj/tiktok-web/tiktok/web/node/_next/static/images/logo-ktok-web/tiktok/web/node/_next/static/images/logo-ktok-web/tiktok/web/node/_next/static/images/logo- 7328701cc .svg" title="TikTok" class="jsx-1929089525 logo-icon"><img src="https://lf16-tiktok-web.ttwstatic.com/obj/tiktok-web/tiktok/web/ktok-web.ttwstatic.com/obj/tiktok-web/tiktok/web/ktok-web. node/_next/static/images/logotext-9b4d14640f93065ec36dab71c806e135.svg" title="TikTok" class="jsx-1929089525 logo-texttext">將部分 html 分解到此,以便您可以更好地看到更多內(nèi)容。
`<iframe src="https:
我嘗試將 html 元素的 iframe 部分添加到上面的 javascript 程式碼中,但它似乎沒(méi)有做任何事情。 我確信我做錯(cuò)了什麼,可能需要對(duì)程式碼進(jìn)行更多調(diào)整。
(document.getElementById('YOUR ID').contentDocument).body;