Get image of main article using PHP

I would like to get the main image for the article, like Facebook does when you post a link (but without selecting a part of the image). The data we need to work with is all HTML pages as variables. The page and URL will be different for each launch of this function.

Are there any libraries or classes that are especially good for getting the bulk of the content, as well as an Instapaper that could help?

+3
source share
1 answer

you can use the PHP DOM classes to parse an HTML page. this will easily allow you to capture the first image and h1 text.

, , p, p- X . .

, , PHP DOM - , .

http://us.php.net/manual/en/book.dom.php

+2

Source: https://habr.com/ru/post/1785193/


All Articles