1
人形でiframeのテキストをどうやって削りますか?人形遣いでiframe
のテキストをこすりこのURLのIFRAMEぼんやりしたテキストFrom Iframe
https://www.w3schools.com/js/tryit.asp?filename=tryjs_events
人形でiframeのテキストをどうやって削りますか?人形遣いでiframe
のテキストをこすりこのURLのIFRAMEぼんやりしたテキストFrom Iframe
https://www.w3schools.com/js/tryit.asp?filename=tryjs_events
からの簡単な再現性の例として
、こすり、This is a paragraph
、あなたがのコンテキストでJavaScriptを評価するために、人形遣いのpage.evaluate
を使用することができますiframe
の内容を返すページ。そうする
手順は次のとおりです。
iframe
要素iframe
のdocument
オブジェクトを取得します。This is a paragraph
をつかみ、このプログラムを書いたiframe
のHTMLを読むためにdocument
オブジェクトを使用します。
const puppeteer = require("puppeteer");
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.w3schools.com/js/tryit.asp?filename=tryjs_events');
const iframeParagraph = await page.evaluate(() => {
const iframe = document.getElementById("iframeResult");
// grab iframe's document object
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
const iframeP = iframeDoc.getElementById("demo");
return iframeP.innerHTML;
});
console.log(iframeParagraph); // prints "This is a paragraph"
await browser.close();
})();
を