Nokogiri 抓取未命中 HTML [英] Nokogiri Scraping Misses HTML

查看:41
本文介绍了Nokogiri 抓取未命中 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Nokogiri 不会抓取 iframe 标签下的任何内容.

Nokogiri isn't grabbing anything beneath the iframe tag.

doc.search("iframe") 仅返回 iframe 标记.doc.search("body.content-frame") 返回空.doc.errors 也返回空.为什么 Nokogiri 不在 iframe 下注册 HTML?我怎样才能抓住它?

doc.search("iframe") returns only the iframe tag. doc.search("body.content-frame") returns empty. doc.errors returns empty also. Why isn't Nokogiri registering the HTML beneath the iframe? How can I grab it?

<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">

    <head></head>
    <body onunload="clearMyTimeInterval()">
       <iframe id="content-frame" frameborder="0" src="/sportsbook/betting-lines/baseball/2014-08-21/?range=day" onload="javascript:checkLoadedFrame(this);" style="background-color: rgb(34, 34, 34); height: 1875px;" name="content-frame" scrolling="no" border="0">
           #document
           <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
            <head></head>
            <body class="content-frame">
             #ETC.......

推荐答案

这是处理它的代码:

page = Mechanize.new.get "http://page_u_need"
page.iframe_with(id: 'beatles').content

这篇关于Nokogiri 抓取未命中 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆