Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you find the "main" picture of a website, given the URL?

Let's say you're given http://nytimes.com How would you pull out the "main" image?

The reason I'm asking is because Flipboard is able to grab the main image from a website, just using the URL.

You could parse out all the image tags. But then what?

like image 255
TIMEX Avatar asked Oct 30 '10 03:10

TIMEX


1 Answers

I don't believe there's a standard method. You could start by looking for an Open Graph Protocol image tag. Facebook uses these to select images for urls posted in status updates and comments.

<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>

If you're prepared to use a third party, Embedly offer this as a chargeable service.

Embedly provides a powerful API to convert standard URLs into embedded videos, images, and rich article previews from 218 leading providers.

like image 130
Ollie Glass Avatar answered Sep 27 '22 21:09

Ollie Glass