I want to make a website with news just like my other site appears on the Internet.
I haven't got enough content. So I want to get content from another news website (Of course, I got permission to copy their content from their site).
For this I used Simple HTML DOM, and it's progressing very well on my other site, but as I apply my script on the release site, it doesn't work (outputs nothing).
Here is the link I want to get the data from: hesspress.com.
Code:
require_once 'simple_html_dom.php';
$lien='http://www.hesspress.com';
$html=new simple_html_dom();
$html->load_file($lien);
$k=$html->find('a',0)->href;
print_r($k);
This is what I would use, you can modify it for your own purposes.
It uses the built-in PHP DOM.
Code:
<?php
$url = 'http://acid3.acidtests.org';
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($handle);
libxml_use_internal_errors(true); // Prevent HTML errors from displaying
$doc = new DOMDocument();
$doc->loadHTML($html);
$link = $doc->getElementsByTagName('a')->item(0);
echo 'Link text: ' . $link->nodeValue;
echo '<br />';
echo 'Link URL: ' . $link->getAttribute('href');
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With