How to use PHP Simple HTML DOM to get data from a remote page traced by a $_GET item? -


when link in a.html clicked :

<tr> <td class="book"><a class="booklink" ref="../collection?file=book1.pdf"> read </a> -blah blah blah </td>   </tr> 

?file=book1.pdf passed b.html:

<?php $src = $_get['file']; ?>  <iframe src="<?php echo $src; ?>" > </iframe> 

question:- how retrieve text "good read-blah blah blah" a.html , paste meta description in b.html using simple html dom? (please know there thousand of listed data in table in a.html)

thank you.

use dom load html document , xpath search it.

// note: if html parse has bad syntax, use: libxml_use_internal_errors(true);  $doc = new domdocument; $doc->loadhtml(file_get_contents('a.html')); if ($doc === false) {     throw new runtimeexception('could not load html'); }  $xpath = new domxpath($doc); $xpathresult = $xpath->query("//a[@href = '../collection?file={$_get['file']}']/.."); if ($xpathresult === false) {     throw new logicexception('something went wrong querying document!'); }  foreach ($xpathresult $domnode) {     echo 'link text: ' . htmlentities($domnode->textcontent) . php_eol; } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -