Hi there. Using simplehtmldom_1_5-1.zip packages @version 1.11 ($Rev: 184 $) .. Suppose to be 1.5?
I'm having a trouble opening cerain URL that opens on avery browser.. Other sites open correctly.
include_once('simple_html_dom.php');
$html = file_get_html("www.telvis.fi/lite/?vw=channel&sh=new&ch=tv2");
foreach($html->find('table tr [class=zeb]') as $d){
echo $d->plaintext;
return;
}
also the PHP 5.3 Windows "VC9 x86 Thread Safe (2011-Aug-23 12:01:10)" on Apacvhe 2.2x yells "mb_detect_encoding" for being undefined..
This works ok.
$html = file_get_html("http://m.yle.fi/w/etusivu");
foreach($html->find(' div[id=page-content]') as $d){
echo $d->plaintext;
return;
}
When writting the site's source into html file and then opening the same way $html = file_get_html("file.html") parsing works.. Error when opening the site with HTTP is ailed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\simple_html_dom.php on line 39
I got this to work: Have to dump the file..
$opts = array('http'=>array('method'=>"GET",'header'=>"Accept-language: en\r\n" ."User-Agent: not for you\r\n"));
$context = stream_context_create($opts);
$url = "http://www.telvis.fi/lite/?vw=channel&sh=new&ch=tv1";
$file = file_get_contents($url, false, $context);
Thanks for opening this issue!
file_get_htmlis most useful for local files. Remote files should be loaded manually and provided tostr_get_htmlinstead.That being said,
file_get_htmlcan handle URLs only if they start with "http" or "https" (as you have figured out yourself). You can check if a URL has the schema defined usingparse_url.Note: There is no way for simple_html_dom to clearly distinguish between local files and remote URLs, so this has to be done by the caller.