<?php
include_once("simple_html_dom.php");
//use curl to get html content
function getHTML($url,$timeout)
{
$ch = curl_init($url); // initialize curl with given url
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); // set useragent
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // max. seconds to execute
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error
return @curl_exec($ch);
}
$html=getHTML("http://www.website.com",10);
// Find all images on webpage
foreach($html->find("img") as $element)
echo $element->src . '<br>';
// Find all links on webpage
foreach($html->find("a") as $element)
echo $element->href . '<br>';
Warning: include_once(): open_basedir restriction in effect. File(simple_html_dom.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/LPka9 on line 2
Warning: include_once(simple_html_dom.php): Failed to open stream: Operation not permitted in /in/LPka9 on line 2
Warning: include_once(): Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/LPka9:6
Stack trace:
#0 /in/LPka9(14): getHTML('http://www.webs...', 10)
#1 {main}
thrown in /in/LPka9 on line 6
Process exited with code 255.
Output for 8.0.13
Warning: include_once(simple_html_dom.php): Failed to open stream: No such file or directory in /in/LPka9 on line 2
Warning: include_once(): Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/LPka9:6
Stack trace:
#0 /in/LPka9(14): getHTML('http://www.webs...', 10)
#1 {main}
thrown in /in/LPka9 on line 6
Process exited with code 255.
Warning: include_once(simple_html_dom.php): failed to open stream: No such file or directory in /in/LPka9 on line 2
Warning: include_once(): Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/LPka9:6
Stack trace:
#0 /in/LPka9(14): getHTML('http://www.webs...', 10)
#1 {main}
thrown in /in/LPka9 on line 6
Process exited with code 255.
Warning: include_once(): open_basedir restriction in effect. File(simple_html_dom.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/LPka9 on line 2
Warning: include_once(simple_html_dom.php): failed to open stream: Operation not permitted in /in/LPka9 on line 2
Warning: include_once(): Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/LPka9:6
Stack trace:
#0 /in/LPka9(14): getHTML('http://www.webs...', 10)
#1 {main}
thrown in /in/LPka9 on line 6
Process exited with code 255.
Output for 7.1.20
Warning: include_once(): open_basedir restriction in effect. File(simple_html_dom.php) is not within the allowed path(s): (/tmp:/in) in /in/LPka9 on line 2
Warning: include_once(simple_html_dom.php): failed to open stream: Operation not permitted in /in/LPka9 on line 2
Warning: include_once(): Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/LPka9:6
Stack trace:
#0 /in/LPka9(14): getHTML('http://www.webs...', 10)
#1 {main}
thrown in /in/LPka9 on line 6
Process exited with code 255.
Warning: include_once(simple_html_dom.php): failed to open stream: No such file or directory in /in/LPka9 on line 2
Warning: include_once(): Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Call to undefined function curl_init() in /in/LPka9 on line 6
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: main(simple_html_dom.php): failed to open stream: No such file or directory in /in/LPka9 on line 2
Warning: main(): Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Call to undefined function curl_init() in /in/LPka9 on line 6
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Warning: main(simple_html_dom.php): failed to open stream: No such file or directory in /in/LPka9 on line 2
Warning: main(): Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Call to undefined function: curl_init() in /in/LPka9 on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Warning: main(simple_html_dom.php): failed to open stream: No such file or directory in /in/LPka9 on line 2
Warning: main(): Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Call to undefined function: curl_init() in /in/LPka9 on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: main(simple_html_dom.php) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /in/LPka9 on line 2
Warning: main() [http://www.php.net/function.main]: Failed opening 'simple_html_dom.php' for inclusion (include_path='.:') in /in/LPka9 on line 2
Fatal error: Call to undefined function: curl_init() in /in/LPka9 on line 6