YQL和cURL-Quote字符没有正确返回

YQL和cURL-Quote字符没有正确返回,curl,yql,Curl,Yql,我使用YQL进行一些屏幕抓取,并且没有正确返回任何类似引号的字符 例如,正在刮取的页面上的标记为: There should not be a “split between what we think and what we do,” YQL将其返回为: There should not be a �split between what we think and what we do,� 这种情况也发生在蜱虫和背蜱虫身上 我的JS是这样的: var qurlString = '&

我使用YQL进行一些屏幕抓取,并且没有正确返回任何类似引号的字符

例如,正在刮取的页面上的标记为:

There should not be a “split between what we think and what we do,”  
YQL将其返回为:

There should not be a �split between what we think and what we do,� 
这种情况也发生在蜱虫和背蜱虫身上

我的JS是这样的:

var qurlString = '&url=' + encodeURIComponent(url);
$.ajax({
  type: "POST",
  url: "/k_sys/qurl.php",
  datatype: "xml",
  data: qurlString,
  success: function(data) {
    //do something
  }
});
我的qurl.php如下所示:

  $BASE_URL = "http://query.yahooapis.com/v1/public/yql";
  $url = my scraped site url;
  $yql_query = "select * from html where url='$url'";
  $yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=xml";
  $session = curl_init($yql_query_url);
  curl_setopt($session, CURLOPT_RETURNTRANSFER,true);
  $xml = curl_exec($session);
  echo $xml;
这是一个cURL问题还是一个YQL问题,我需要做什么来修复它


谢谢

这听起来像是一个字符编码问题。您正在抓取的站点可能正在使用head元素中的meta标记设置字符集,而不是将服务器配置为正确标识http标头中的字符编码。找出站点使用的字符编码(应该可以在浏览器的“视图”菜单中找到),并将字符集键添加到YQL查询中

YQL指南中的示例:

select * from html where url='http://example.com' and charset='iso-8559-1' 

源页面由IIS和ASP提供服务。我最后不得不做一个简单的搜索和替换,比如:

str_ireplace(chr(145), chr(39), $html)