从JSON对象中的非结构化字符串提取html标记和数据

从JSON对象中的非结构化字符串提取html标记和数据,html,json,node.js,web-services,parsing,Html,Json,Node.js,Web Services,Parsing,我正在使用NodeJS和Express调用Eventbrite的web服务。从下面的JSON对象中,我需要提取img标记和相关数据(src、width、height) [ { name: 'Sense 5K - Austin Pre-Registration', url: 'http://austinpreregister.eventbrite.com/?aff=SRCH', start: '2014-10-01 09:00:00', description: '<

我正在使用NodeJS和Express调用Eventbrite的web服务。从下面的JSON对象中,我需要提取img标记和相关数据(src、width、height)

[ { name: 'Sense 5K - Austin Pre-Registration',
    url: 'http://austinpreregister.eventbrite.com/?aff=SRCH',
    start: '2014-10-01 09:00:00',
    description: '<P><IMG STYLE="display: block; margin-left: auto; margin-right: auto;" SRC="https://evbdn.eventbrite.com/s3-s3/eventlogos/90039995/about.png" ALT="" WIDTH="568" HEIGHT="138"></P>\r\n<P><IMG STYLE="vertical-align: middle; display: block; margin-left: auto; margin-right: auto;" SRC="https://evbdn.eventbrite.com/s3-s3/eventlogos/90039995/bluedawntour1.jpg" ALT="" WIDTH="568" HEIGHT="227"></P>',
    venue: 
     { city: 'Austin',
       name: '',
       country: 'United States',
       region: 'TX',
       longitude: -76.956325,
       postal_code: '',
       address_2: '',
       address: '',
       latitude: 38.861568,
       country_code: 'US',
       id: 5936809,
       'Lat-Long': '38.861568 / -76.956325' },
    organizer: 
     { url: 'http://www.eventbrite.com/o/sense-5k-6113542315',
       description: '\r\nAlong this enchanting journey you will encounter five Sense Scenes--each crafted to trigger an individual sense.The event is crowned with Sense Live, an unforgettable show and after party featuring pyrotechnics, dazzling special effects, a professional EDM DJ, live acrobatic entertainment, heart-pounding music, and the rhythm of your dancing. The purpose of Sense 5K is not to compete, but to experience! Every Sense 5K event benefits a local charity.\r\n \r\n',
       long_description: '\r\nAlong this enchanting journey you will encounter five Sense Scenes--each crafted to trigger an individual sense.The event is crowned with Sense Live, an unforgettable show and after party featuring pyrotechnics, dazzling special effects, a professional EDM DJ, live acrobatic entertainment, heart-pounding music, and the rhythm of your dancing. The purpose of Sense 5K is not to compete, but to experience! Every Sense 5K event benefits a local charity.\r\n ',
       id: 6113542315,
       name: 'Sense 5K' } } ]
[{name:'Sense 5K-奥斯汀预注册',
网址:'http://austinpreregister.eventbrite.com/?aff=SRCH',
开始:“2014-10-01 09:00:00”,
描述:“

\r\n

”, 地点: {城市:'奥斯汀', 名称:“”, 国家:'美国', 地区:'TX', 经度:-76.956325, 邮政编码:'', 地址2:“”, 地址:'', 纬度:38.861568, 国家代码:“美国”, 身份证号码:5936809, '拉特朗':'38.861568/-76.956325'}, 组织者: {url:'http://www.eventbrite.com/o/sense-5k-6113542315', 描述:“\r\n在这段迷人的旅程中,你将遇到五个感官场景——每一个都是为了触发个人感觉而精心制作的。这场活动的主题是感官直播,一场令人难忘的表演,以及派对后的烟火表演、令人眼花缭乱的特效、专业的EDM DJ、现场杂技娱乐、震撼人心的音乐和音乐的节奏您的舞蹈。Sense 5K的目的不是为了比赛,而是为了体验!每个Sense 5K活动都有利于当地的慈善机构。\r\n\r\n', 长长的描述:“\r\n在这段迷人的旅程中,你将遇到五个感官场景——每一个都是为了触发个人感觉而精心制作的。这场活动的主题是感官直播,一场令人难忘的表演,以及派对后的烟火表演、令人眼花缭乱的特效、专业EDM DJ、现场杂技娱乐、震撼人心的音乐和节奏m您的舞蹈。Sense 5K的目的不是为了比赛,而是为了体验!每个Sense 5K活动都有利于当地的慈善机构。\r\n', id:6113542315, 名称:'Sense 5K'}}]

此API的响应各不相同(有时不包含图像,有时仅包含图像,有时在其他html中包含图像),因此我正在寻找一种干净的方法来运行整个JSON对象,查找img标记,并在它们出现时处理它们,而不管它们出现在对象中的何处

使用以下JavaScript和jQuery:

var returnedObject = JSON.parse(returnedJSON);
$.each(returnedObject, function(index, value) {
    var $element = $(value.description);
    var images = $element.find('img');
    $.each(images, function(index, value) {
        console.log(value);
    });
});

OP明确指出,图像可以出现在对象中的任何位置。这个答案只会在
描述
属性中找到。为什么要使用jquery呢?其次,在服务器端使用jquery和NodeJS的最佳选择是什么?我曾使用cheerio来抓取html页面和操作DOM,但在本例中,我尝试在JSON上迭代。