1

我想解析一个 facebook 提要。

这是我的 json 网址:http ://www.facebook.com/feeds/page.php?id=199009743552420&format=json

所以我得到了这种类型的数据作为回应:

 "content": "\u003Ca href=\"\/l.php?u=http\u00253A\u00252F\u00252Fwww.youtube.com\u00252Fwatch\u00253Fv\u00253D9_PaHtaKAug\u002526list\u00253DPLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n\u002526index\u00253D1\u002526feature\u00253Dplpp_video&h=0AQEQfrMH&s=1\" id=\"\" title=\"\" target=\"\" onclick=\"LinkshimAsyncLink.swap(this, "\\\/l.php?u=http\\u00253A\\u00252F\\u00252Fwww.youtube.com\\u00252Fwatch\\u00253Fv\\u00253D9_PaHtaKAug\\u002526list\\u00253DPLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n\\u002526index\\u00253D1\\u002526feature\\u00253Dplpp_video&h=0AQEQfrMH&s=1");\" style=\"\" rel=\"nofollow\" onmouseover=\"LinkshimAsyncLink.swap(this, "http:\\\/\\\/www.youtube.com\\\/watch?v=9_PaHtaKAug&list=PLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n&index=1&feature=plpp_video");\">\u003Cimg class=\"img\" src=\"http:\/\/external.ak.fbcdn.net\/safe_image.php?d=AQDshpKwwDhCYH9k&w=130&h=130&url=http\u00253A\u00252F\u00252Fi2.ytimg.com\u00252Fvi\u00252F9_PaHtaKAug\u00252Fmqdefault.jpg\" alt=\"\" style=\"height:90px;\" \/>\u003C\/a>\u003Cbr\/>\u003Ca href=\"\/l.php?u=http\u00253A\u00252F\u00252Fwww.youtube.com\u00252Fwatch\u00253Fv\u00253D9_PaHtaKAug\u002526list\u00253DPLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n\u002526index\u00253D1\u002526feature\u00253Dplpp_video&h=PAQEzb06t&s=1\" id=\"\" target=\"_blank\" onclick=\"LinkshimAsyncLink.swap(this, "\\\/l.php?u=http\\u00253A\\u00252F\\u00252Fwww.youtube.com\\u00252Fwatch\\u00253Fv\\u00253D9_PaHtaKAug\\u002526list\\u00253DPLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n\\u002526index\\u00253D1\\u002526feature\\u00253Dplpp_video&h=PAQEzb06t&s=1");\" style=\"\" rel=\"nofollow\" onmouseover=\"LinkshimAsyncLink.swap(this, "http:\\\/\\\/www.youtube.com\\\/watch?v=9_PaHtaKAug&list=PLc4q0uG_h6x5tA_L3kHK6TE9TV6skf14n&index=1&feature=plpp_video");\">The Dissident Files - Ausama Monajed at THiNK 2012\u003C\/a>\u003Cbr\/>www.youtube.com\u003Cbr\/>Ausama Monajed in conversation with NDTV's Vishnu Som in Tehelka's THiNK 2012 session on "The Troubled Looking Glass: Why You Should Care About Syria" For mo... "

它包含图像徽标 url、视频 url、....那么我该如何解析这种类型的数据呢?

请帮我。

感谢您

4

1 回答 1

0

从 json 解析内容字段后,您需要再次解析它,记住现在您正在处理 html 代码。如果你想做一些复杂的查询,你必须使用 XPath 和 libxml2 库。

请参阅:iOS:解析 html 标签的最佳方式?

如果你只想做一个简单的查询,你可以遍历字符串并选择你想要的

于 2013-03-20T11:53:05.987 回答