It is possible to use cURL to get a certain ID or CLASS of a page

0

I'm studying php and I was seeing the cURL function and I wanted to know if it's possible to get the contents of only one ID from another page

example:

<div id="teste2">
     n pegar esse aqui
    </div>
<div id="teste">
 Pegar somente o conteúdo que esta aqui dentro
</div>
    
asked by anonymous 13.07.2018 / 19:58

1 answer

0

It will not be too difficult if you use something more appropriate to what you want to do.

You need a library to help you get the DOM interpretation returned.

You can use DiDom

link

use DiDom\Document;

$document = new Document('http://wp.test/teste.html', true);
$posts = $document->find('#teste2');
echo $posts[0]->text();
    
13.07.2018 / 20:09