开发者

Extract image URL from HTML text

开发者 https://www.devze.com 2023-01-23 05:53 出处:网络
In Objective-C what is the best method to extract an image url from HTML text? I\'ve got a chunk of HTML text which may contain one or more images. I want to be a开发者_运维百科ble to get the src URL

In Objective-C what is the best method to extract an image url from HTML text?

I've got a chunk of HTML text which may contain one or more images. I want to be a开发者_运维百科ble to get the src URL of each image.


If you don't mind limiting yourself to iOS 4, you can use the new text checking APIs. The one you want is NSTextCheckingTypeLink and the NSRegularExpression class.


This seems to be answered over here: parsing HTML on the iPhone

The second answer down has a detailed explanation, however you will just have to change the xpath expression to match your image tags.

0

精彩评论

暂无评论...
验证码 换一张
取 消