iOS 后台返回的HTML数据怎么解析

iOS 码拜 9年前 (2016-05-11) 1801次浏览
{
data = “<!DOCTYPE html><html><head><title>\U8fea\U5965\U7ea2\U6bd2\U5973\U58eb\U9999\U6c34EDT 50ml</title><meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /><meta name=”viewport” content=”width=device-width, initial-scale=0.4″><meta name=”viewport” content=”initial-scale = 0.4 , minimum-scale = 0.4 , maximum-scale = 1.0″ /><style>img {width: auto\9;height: auto;vertical-align: middle;border: 0;-ms-interpolation-mode: bicubic;max-width: 100%; }html { font-size:100%; } </style><base href=”http://192.168.6.137/” /></head><body><p>
\n\t<br />
\n</p>
\n<p style=”color:#4C4C4C;font-size:14px;”>
\n\t<a href=”http://wxmiqi.wushuai.net/mobile/goods.php?id=77″ target=”_blank”><img src=”/images/upload/image/20150325/20150325234746_39270.gif” alt=”” /></a>
\n</p>
\n<p style=”color:#4C4C4C;font-size:14px;”>
\n\t<span style=”font-family:Arial;”><a href=”http://wxmiqi.wushuai.net/mobile/goods.php?id=117″ target=”_blank”>\U9996\U9875</a></span>
\n</p>
\n<p style=”color:#4C4C4C;font-size:14px;”>
\n\t<span style=”font-family:Arial;”><img src=”http://img.miqi.cn/static/team/2012/0530/13383634752884.jpg” alt=”” style=”border:0px;” />HYPNOTIC POISON\U86ca\U5a9a\U5947\U8469\U4e5f\U662fJohn Galliano\Uff0c\U8fd9\U4f4d\U5f53\U4ee3\U6700\U5bcc\U624d\U534e\U7684\U8bbe\U8ba1\U5e08\U52a0\U5165Dior\U540e\U521b\U4f5c\U7684\U7b2c\U4e00\U6b3e\U9999\U6c34\Uff0c\U5728\U4e30\U76c8\U3001\U99a5\U90c1\U800c\U8ff7\U5e7b\U7684\U9999\U8c03\U95f4\Uff0cHYPNOTIC POISON\U51c6\U786e\U5730\U6355\U6349\U5230\U4e86\U6fc0\U60c5\U7684\U91ca\U653e\U70b9\Uff0c\U6070\U5982\U4e00\U9053\U795e\U79d8\U7684\U5492\U8bed\U6f14\U7ece\U7740\U4e00\U79cd\U5e7b\U8c61\Uff0cHYPNOTIC POISON\U5728\U6781\U7aef\U611f\U6027\U4e0e\U6fc0\U8361\U4e4b\U95f4\U4ee4\U4eba\U65e0\U6cd5\U6297\U62d2\Uff0c\U8be0\U91ca\U51fa\U4ee4\U4eba\U76ee\U7729\U795e\U8ff7\U7684\U8bf1\U60d1\U3002<br />
\n<strong><span style=”color:#FF6666;”>\U7cbe\U81f4\U74f6\U8eab\Uff1a</span></strong>\U540cPOISON\U7cfb\U5217\U7684\U5176\U4ed6\U6b3e\U5f0f\U4e00\U6837\Uff0cHYPNOTIC POISON\U86ca\U5a9a\U5947\U8469\U7684\U74f6\U8eab\U4ea6\U5341\U5206\U8d34\U5408\U5b83\U81ea\U8eab\U7684\U4e3b\U9898\Uff0c\U4eba\U9020\U7ea2\U5b9d\U77f3\U95ea\U52a8\U7740\U6df1\U9083\U7684\U9b45\U529b\Uff0c\U8bf1\U60d1\U4e00\U89e6\U5373\U53d1\U3002<br />
\n<strong><span style=”color:#FF6666;”>\U77db\U76fe\U7684\U9999\U8c03\Uff1a</span></strong>\U5f02\U5e38\U77db\U76fe\U7684\U4e00\U6b3e\U9999\U6c34\Uff0c\U72b9\U5982\U5973\U4eba\U7684\U5185\U5fc3\U4e00\U822c\U6349\U6478\U4e0d\U5b9a\Uff0c\U6563\U53d1\U795e\U79d8\U7684\U9b45\U529b\Uff01<br />
\n<strong><span style=”color:#FF6666;”>\U6e05\U6f88\U7684\U524d\U5473\Uff1a</span></strong>\U9ece\U5df4\U5ae9\U73ab\U7470\U7684\U6e05\U65b0\U5a07\U8273\U8ba9\U4eba\U4e00\U77a5\U60ca\U9e3f\Uff0c\U6e05\U6f88\U7684\U9178\U5473\U8ba9\U4eba\U8033\U76ee\U4e00\U65b0\U3002</span>
\n</p>
\n<p style=”color:#4C4C4C;font-size:14px;”>
\n\t<span style=”font-family:Arial;color:#FF6666;”><strong>\U6e29\U6696\U539a\U91cd\U7684\U4e2d\U5473\Uff1a</strong></span><span style=”font-family:Arial;”>\U4e73\U8102\U7684\U9999\U5473\U7ef5\U8f6f\U539a\U91cd\Uff0c\U4e45\U4e45\U4e0d\U7edd\U3002\U8f7b\U55c5\U7740\U6e29\U6696\U7684\U4e73\U9999\Uff0c\U5fc3\U7075\U5728\U6170\U85c9\U4e2d\U6e10\U6e10\U653e\U677e\U3002Hypnotic\Uff0c\U5b9b\U5982\U50ac\U7720\U822c\U7684\U9b54\U6cd5\U86ca\U60d1\U3002<br />
\n&nbsp;</span><strong><span style=”color:#FF6666;”>\U77db\U76fe\U590d\U6742\U7684\U540e\U5473\Uff1a</span></strong><span style=”font-family:Arial;”>\U4e73\U8102\U9999\U6c14\U4e2d\U6df7\U5408\U7740\U8f9b\U54b8\Uff0c\U8089\U6842\U9690\U9690\U51fa\U6ca1\U5176\U95f4\U3002\U90a3\U662f\U4e00\U79cd\U6781\U5176\U590d\U6742\U7684\U60c5\U611f\U3002\U5473\U9053\U5c31\U50cf\U662f\U597d\U5403\U7684\U54b8\U5976\U6cb9\U3002\U4e73\U8102\U7684\U7ef5\U8f6f\U539a\U91cd\Uff0c\U5305\U88f9\U7740\U54b8\U5473\U8f9b\U5473\U7684\U514b\U5236\U4e0e\U538b\U6291\U2014\U2014\U5c31\U50cf\U662f\U4f20\U8bf4\U4e2d\U7684\U201c\U7981\U6b32\U4e3b\U4e49\U8005\U201d\U3002\U90a3\U662f\U4e00\U79cd\U6781\U7aef\U7684\U523b\U610f\U538b\U5236\U2014\U2014\U53ea\U4e3a\U4fdd\U6301\U8eab\U5fc3\U7684\U72ec\U7acb\U548c\U6e05\U9192\U3002\U5982\U6b64\U538b\U6291\U5982\U6b64\U4f4e\U8ff7\Uff0c\U5c31\U8fde\U7a7a\U6c14\U4e2d\U90fd\U5f25\U6f2b\U8d77\U4e00\U79cd\U7406\U667a\U548c\U9690\U5fcd\U5473\U9053\U3002\U8fd9\U7b80\U76f4\U5c31\U50cf\U662f\U7406\U667a\U4e0e\U60c5\U611f\U7684\U6597\U4e89\Uff01\U7406\U667a\U538b\U6291\Uff0c\U60c5\U611f\U51b2\U51fb\Uff0c\U5c31\U5728\U8fd9\U53cd\U53cd\U590d\U590d\U7684\U77db\U76fe\U7ea0\U7ed3\U4e2d\Uff0c\U60c5\U611f\U7ec8\U4e8e\U7efd\U653e\U51fa\U6700\U70ed\U70c8\U7684\U8bf1\U60d1\Uff01<br />
\n</span>
\n</p>
\n<p style=”color:#4C4C4C;font-size:14px;”>
\n\t<span style=”font-family:Arial;”><span style=”color:#FF6666;”><strong>\U9999\U8c03\Uff1a</strong></span>\U4e1c\U65b9\U9999\U8c03<br />
\n<span style=”color:#FF6666;”><strong>\U524d\U8c03\Uff1a</strong></span>\U82e6\U674f\U4ec1\Uff1a\U751f\U957f\U4e8e\U610f\U5927\U5229\U5bd2\U51b7\U7684\U5357\U65b9\Uff0c\U524d\U8c03\U900f\U7740\U9690\U7ea6\U7684\U82e6\U5473\U3002<br />
\n<span style=”color:#FF6666;”><strong>\U4e2d\U8c03\Uff1a</strong></span>\U8309\U8389\Uff1a\U662f\U5973\U6027\U67d4\U7f8e\U7684\U8c61\U5f81\U3002\U8309\U8389\U82b1\U662f\U4e16\U754c\U4e0a\U9999\U6c34\U63d0\U70bc\U4e2d\U6700\U5e38\U7528\U5230\U7684\U9999\U6599\Uff0c\U5b83\U662f\U6709\U81ea\U5df1\U72ec\U7279\U7684\U9999\U5473\U53c8\U975e\U5e38\U6613\U788e\U7684\U82b1\U79cd\Uff0c\U65f6\U800c\U72c2\U91ce\U548c\U5954\U653e\Uff0c\U65f6\U800c\U53c8\U50cf\U671d\U9732\U4e00\U822c\U7eaf\U6d01\U3002<br />
\n<span style=”color:#FF6666;”><strong>\U540e\U8c03\Uff1a</strong></span>\U9999\U8349\Uff1a\U6709\U4e00\U70b9\U751c\U751c\U7684\U5473\U9053\U3002</span>
\n</p>
\n<div>
\n\t<span style=”font-family:Arial;”><br />
\n</span>
\n</div>
\n<p>
\n\t<br />
\n</p></body></html>”;
status =     {
succeed = 1;
};
}
后台返回了这种数据 之前没遇到过 该怎么解析 是loadData吗   求具体的代码
解决方案

50

给你推荐一个库
https://github.com/topfunky/hpple
可以直接解析html
#import “TFHpple.h”
NSData  * data      = [NSData dataWithContentsOfFile:@”index.html”];
TFHpple * doc       = [[TFHpple alloc] initWithHTMLData:data];
NSArray * elements  = [doc search:@”//a[@class=”sponsor”]”];
TFHppleElement * element = [elements objectAtIndex:0];
[e text];                       // The text inside the HTML element (the content of the first text node)
[e tagName];                    // “a”
[e attributes];                 // NSDictionary of href, class, id, etc.
[e objectForKey:@”href”];       // Easy access to single attribute
[e firstChildWithTagName:@”b”]; // The first “b” child node

50

iOS 后台返回的HTML数据怎么解析
妈蛋,后台要给传这东西。要么就给个H5的链接,要么让后台滚蛋本人用原生写。

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明iOS 后台返回的HTML数据怎么解析
喜欢 (0)
[1034331897@qq.com]
分享 (0)