“财产”是指财产。使用 jquery、跨域 ajax 和 YQL 获取开放图数据时,响应中缺少元标记的属性
我正在使用 jquery 1.5.1、James Padolsey Cross Domain Ajax 0.11,它使用 YQL 来获取外部站点。
这是我的代码
$.ajax({
url: "http://ogp.me/",
type: "GET",
crossDomain: true,
success: function (res) {
console.log($(res.responseText));
});
问题是在responseText中,所有元标记都缺少“property”属性。
页面的源代码如下所示:
这就是 firebug 显示的 responseText 值是:
这是YQL问题吗?有没有更好的方法从外部站点获取开放图数据?
I'm using jquery 1.5.1, James Padolsey Cross Domain Ajax 0.11 which uses YQL to get external sites.
this is my code
$.ajax({
url: "http://ogp.me/",
type: "GET",
crossDomain: true,
success: function (res) {
console.log($(res.responseText));
});
The problem is that in the responseText, all meta tags are missing the "property" property.
this is what the source code of the page looks like:
<meta property="og:title" content="Open Graph Protocol" />
this is what firebug shows the responseText value is:
<meta content="Open Graph Protocol"/>
Is this a YQL problem? Is there a better way to get open graph data from external sites?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于仍然遇到此问题的任何人,您只需在查询中添加
AND compat="html5"
即可在结果中获得property
属性。For anyone that's still coming across this question, you just have to add
AND compat="html5"
to your queries and you will get theproperty
attributes in your results.YQL 的
html
数据表(由该跨域 AJAX 插件使用)运行 HTML Tidy ( info)在从远程服务器返回的 HTML 上。在此过程中,您要查找的property
属性将被删除(可能是因为 Tidy 将它们视为无效)。YQL's
html
data table, which is being used by that cross-domain AJAX plugin, runs HTML Tidy (info) on the HTML returned from the remote server. During this process, theproperty
attributes that you are looking for are removed (likely because Tidy sees them as invalid).