我应该使用Yahoo-Pipes抓取div的内容吗? [英] Should I use Yahoo-Pipes to scrape the contents of a div?

查看:68
本文介绍了我应该使用Yahoo-Pipes抓取div的内容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出:

  • Url - http://www.contoso.com/search.php?q={param} returns:

-html-
--body-
{...}
--- div id ='foo'-
---- div id ='page1'/-
---- div id ='page2'/-
---- div id ='page3'/-
---- div id ='pageN'/-
---/div-
{...}
-/body-
-/html-

-html-
--body-
{...}
---div id='foo'-
----div id='page1'/-
----div id='page2'/-
----div id='page3'/-
----div id='pageN'/-
---/div-
{...}
--/body-
-/html-

想要:

  • div id ='foo'的innerHtml必须由客户端获取(即Javascript).
    • 它将分为多个离散项(即div id ='page1'到div id ='pageN').
    • The innerHtml of div id='foo' must be fetched by the client (i.e. Javascript).
      • It will be split into discrete items (i.e. div id='page1' to div id='pageN').

      问题:

      • Yahoo-Pipes可以帮助格式化数据以便于使用吗?
        • 缺少DOM解析器让我停顿了.
        • Could Yahoo-Pipes help format the data for easier consumption?
          • The lack of a DOM parser gives me pause.

          推荐答案

          您可以使用 YQL 模块,该模块允许您获取任意URL,然后使用XPath解析它们.一个简单的YQL查询:

          You can use the YQL module, which allows you to fetch arbitrary URLs and then parse them with XPath. A sample YQL query:

          select * from html where url="http://finance.yahoo.com/q?s=yhoo" and
            xpath='//div[@id="yfi_headlines"]/div[2]/ul/li/a'
          

          这篇关于我应该使用Yahoo-Pipes抓取div的内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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