• Hi, try to grab specific content from a website (have permission). But instead of grabbing the whole page I want to grab the content surround within the div named ‘main’.
    I have the following so far but this just displays the whole page.

    <?php
    			$ch = curl_init("https://www.......");
    			curl_setopt($ch, CURLOPT_HEADER, 0);
    			curl_exec($ch);
    			curl_close($ch);
    			?>
Viewing 1 replies (of 1 total)
  • Thread Starter keyaspects

    (@keyaspects)

    I have the following now but this only grabs the text (no images)..

    <?php $page = file_get_contents('https://www.testsite/testpage3.php');
    			$doc = new DOMDocument();
    			$doc->loadHTML($page);
    			$divs = $doc->getElementsByTagName('div');
    			foreach($divs as $div) {
    			if ($div->getAttribute('id') === 'main') {
    				 echo $div->nodeValue;
    			}
    		}
    
    			?>
Viewing 1 replies (of 1 total)
  • The topic ‘grab specific content from a website into a wordpress page’ is closed to new replies.