簡體   English   中英

如何刮<html> ...</html> 在另一個里面<html> ...</html> 與木偶師

[英]How to scrape <html>...</html> INSIDE another <html>...</html> with puppeteer

好的,所以我試圖用 node.js puppeteer 抓取的頁面結構是這樣的

    <html lang = "en">
    ....
       <html xmlns="https://www.w3.org/1999/xhtml" lang="en">
            <a href = "link I'm trying to go to">Go to link</a>
       </html>
    </html>

我試圖通過選擇器和 XPath 單擊。 兩者都沒有奏效,我三重檢查了兩者是否正確。 感覺跟這個內嵌的html有關系,不知道怎么處理? 任何人都可以幫忙嗎?

其他評論指出無法從父文檔訪問 iframe 內的內容。 我再次檢查了代碼,發現它實際上是這樣的結構:

<html lang = "en">
....
   <iframe src = "url">
       <html xmlns="https://www.w3.org/1999/xhtml" lang="en">
           <a href = "link I'm trying to go to">Go to link</a>
       </html>
   </iframe>
</html>

所以我所要做的就是 page.goto(url),然后我就可以正常抓取了。 謝謝大家!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM