1

I have an application that is pulling articles from the web and I need to retrieve the URL for the first image in an article. Here's an example of the code for these images:

<img alt="Twitter (zpower)" src="http://www.example.com/image.png" width="630" height="420">

I need to get just the value for the src. How would I do this?

2 Answers 2

4

You'll need to parse the HTML and extract the src attribute. You could do it by hand, but a better way is to rely on someone else's parsing library (for instance, ElementParser).

Sign up to request clarification or add additional context in comments.

Comments

2

I'd like to second @ravuya's response, but also mention that you can also use the built in NSXMLParser to do the parsing for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.