目标C从HTML字符串获取图像 [英] Objective c getting image from an html string

查看:68
本文介绍了目标C从HTML字符串获取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些代码来从这样的字符串中提取

Hi i need some code to extract from a string like this

<div><a href="http://3.bp.blogspot.com/-uBx6ZoJ1DmY/TWPc1zD7aMI/AAAAAAAAANE/xeTZXtv4KYk/s1600/ipad-light-peak.jpg"><img border="0" height="260" src="http://3.bp.blogspot.com/-uBx6ZoJ1DmY/TWPc1zD7aMI/AAAAAAAAANE/xeTZXtv4KYk/s320/ipad-light-peak.jpg" width="320" /></a></div><div>Come ormai tutti sappiamo, il nuovo iPad 2 è già in produzione da un po' di tempo, e, secondo recentissime voci, il nuovo iPad sarà equipaggiato con Light Peak.&#160;</div><div><br /></div><div>Light Peak è una tecnologia sviluppata da Intel che utilizza la fibra ottica per la trasmissione dei dati, portando così la velocità di trasferimento dei dati da PC/Mac a iPad ad una velocità altissima.&#160;</div><div><br /></div><div>Una connessione Light Peak su iPad 2 è secondo noi alquanto improbabile, dato che ormai il dock a 30 pin è quasi uno "standard" di comunicazione dei dispositivi Apple; inoltre se su iPad 2 sarà presente solo Light Peak, tutte le case che producono accessori per iPad dovranno riprogettare il loro prodotti.</div><div><br /></div><div>E voi, cosa ne pensate ? Fatecelo sapere utilizzando il form qui sotto.</div><div><img width="1" height="1" src="https://blogger.googleusercontent.com/tracker/5674629894325206938-2710160962386980433?l=eugystyle.blogspot.com" alt="" /></div>

图像的路径...在此esample代码中,我需要"http://3.bp.blogspot.com/-uBx6ZoJ1DmY/TWPc1zD7aMI/AAAAAAAAANE/xeTZXtv4KYk/s320/ipad-light-peak.jpg "

The path of the image... in this eìcode for esample I need the "http://3.bp.blogspot.com/-uBx6ZoJ1DmY/TWPc1zD7aMI/AAAAAAAAANE/xeTZXtv4KYk/s320/ipad-light-peak.jpg"

谢谢

推荐答案

如果您不打算解析html,则可以使用简单的substringFromIndex和substringToIndex来解决问题.

if you are not going to parse the html then a simple substringFromIndex and substringToIndex will do the trick.

NSString *yourFullURL = fullHTMLString;
NSRange t = [yourFullURL rangeOfString:@"\"><img border=\"0\""];

//check range exists
if(t.location !=NSNotFound){
    NSString *yourJPGURL = [yourFullURL substringToIndex:t.location];
}
// this will give you a new string up to the end of the URL//
// then repeat for the first part using a new NSRange for the beginning of
// the URL, use range.location+x  (where x is the number of characters to add as NSRange
// returns the beginning of the string you search for.

这篇关于目标C从HTML字符串获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆