mercredi 5 août 2015

How to fetch div data from remote website page and store it as a variable? [duplicate]


This question already has an answer here:

Suppose a website site.com has a div element <div class="abc">Some Texts</div> in each page where "Some Texts" varies in each page, how do I fetch the data "Some Texts" and store it in a PHP variable? I use the following code to replace all the contents up to <div class ="abc"> I want to store The values in the div which has class abc.

<?php
$file=curl_get('http://ift.tt/1Hq0qll'.$_SERVER['QUERY_STRING']);

$file=preg_replace('|<!DOCTYP(.*?)<div class="abc">|is', '<div class="abc">',$file);

echo $file;
?>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire