【问题标题】:How to ignore some tags (B,I,STRONG) in the response?如何忽略响应中的一些标签(B、I、STRONG)?
【发布时间】:2012-11-10 15:54:27
【问题描述】:

我尝试使用 YQL 抓取一些网站(用于 Appcelerator Titanium 移动应用)。

我需要的数据在一个 A 标签内,但它是格式化的:

<a href="...">
     <strong>Drugs</strong> and Culture</font>
</a>

所以,当我运行如下查询时:

select * from html where  url='...'  and xpath="//table[2]/tr/td[2]//a"

我明白了:

 {"strong": "Drugs", "content": "\n and Culture"}

我需要 YQL 忽略那些“强”标签并以文本值响应:

{content: "Drugs and Culture"}

你知道怎么做吗?

【问题讨论】:

    标签: xml json xpath yql


    【解决方案1】:

    我不知道 YQL,但产生所需结果的纯 XPath 表达式是:

    normalize-space(//table[2]/tr/td[2]//a)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多