【问题标题】:YQL Losing HTML Element Attributes?YQL 丢失 HTML 元素属性?
【发布时间】:2011-10-02 01:35:20
【问题描述】:

YQL Console Link

查询:

select * from html where url='http://www.cbs.com/shows/big_brother/video/' and xpath='//div[@id="cbs-video-metadata-wrapper"]/div[@class="cbs-video-share"]/a'

返回:

<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
    yahoo:count="1" yahoo:created="2011-07-09T23:14:02Z" yahoo:lang="en-US">
    <diagnostics>
        <publiclyCallable>true</publiclyCallable>
        <url execution-time="146" proxy="DEFAULT"><![CDATA[http://www.cbs.com/shows/big_brother/video/]]></url>
        <user-time>163</user-time>
        <service-time>146</service-time>
        <build-version>19262</build-version>
    </diagnostics> 
    <results>
        <a class="twitter-share-button" href="http://twitter.com/share"/>
    </results>
</query>

应该返回类似于:

    <results>
        <a href="http://twitter.com/share" data-url="http://www.cbs.com/shows/big_brother/video/2045825951/big-brother-episode-1" class="twitter-share-button"></a>
    </results>

如果我退出查询一级,它会完全去除元素,我也可以使用它来获取我需要的数据。

【问题讨论】:

    标签: yahoo yql yahoo-pipes


    【解决方案1】:

    我们现在有一个新的 html 解析器,可以识别自定义属性。

    添加compat="html5" 以触发新的解析器。

    例如:

    select * from html where url = "http://mydomain.com" and compat="html5"
    

    【讨论】:

      猜你喜欢
      • 2021-08-20
      • 2021-09-07
      • 1970-01-01
      • 2022-08-02
      • 2021-11-16
      • 2023-01-02
      • 1970-01-01
      • 2017-01-12
      相关资源
      最近更新 更多