Javascript 只想拉JSON类而不是所有的数据

Javascript 只想拉JSON类而不是所有的数据,javascript,jquery,json,ajax,yql,Javascript,Jquery,Json,Ajax,Yql,尝试使用$.getJSON和YQL仅从具有唯一名称的类中提取文本。现在它提取所有数据并去掉标签。有人知道这能否实现吗 function filterData(data){ // filter all the nasties out // no body tags data = data.replace(/<?\/body[^>]*>/g,''); // no linebreaks data = data.replace(/[\r|\n

尝试使用
$.getJSON
和YQL仅从具有唯一名称的类中提取文本。现在它提取所有数据并去掉标签。有人知道这能否实现吗

  function filterData(data){
    // filter all the nasties out
    // no body tags
    data = data.replace(/<?\/body[^>]*>/g,'');
    // no linebreaks
    data = data.replace(/[\r|\n]+/g,'');
    // no comments
    data = data.replace(/<--[\S\s]*?-->/g,'');
    // no noscript blocks
    data = data.replace(/<noscript[^>]*>[\S\s]*?<\/noscript>/g,'');
    // no script blocks
    data = data.replace(/<script[^>]*>[\S\s]*?<\/script>/g,'');
    // no self closing scripts
    data = data.replace(/<script.*\/>/,'');

    // the below doesn't work of course, but if I could use jQuery I would do as follows:
    data = $(data).find('.count').text();
    return data;
  }

我怎么能只显示类“count”上的“27”而不是域上的所有数据呢?

我认为您在这里没有太多选择,
yql
为您提供了一个代理来查询不在域上的资源。您可以创建自己的服务器端代理,该代理可以过滤结果,并以
json
格式返回所需的输出。

我必须做的事情是在YQL语句末尾使用XPATH,但我没有意识到这一点

    select content from html where url="http://www.resellerratings.com/store/Burkett_Restaurant_Equipment_Supplies"
 and xpath="//span[@class='count']"

如果只想拉取1个类(包含27个类),div[0].div[0].div.span.span[0]。内容将返回27How/where-you-use-YQL,以及要做什么?
    select content from html where url="http://www.resellerratings.com/store/Burkett_Restaurant_Equipment_Supplies"
 and xpath="//span[@class='count']"