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?
You’ll need to parse the HTML and extract the
srcattribute. You could do it by hand, but a better way is to rely on someone else’s parsing library (for instance, ElementParser).