Page 1 of 1

file_get_html error on one site

Posted: Sat Sep 03, 2011 11:58 am
by mavera2
I'm using simple html dom parser.
I used it in my web site successfully.
But i changed my host company and i can't run my existing codes.
"file_get_html" works on some sites. doesn't work on some sites.
i couldn't understand the problem.

This one works:

Code: Select all

include_once ('simple_html_dom.php');
$html1 = file_get_html('http://www.yahoo.com');
echo $html1;

Although web site can be opened from my browser, This one doesn't work in php script:

Code: Select all

include_once ('simple_html_dom.php');
$html2 = file_get_html('http://www.eksisozluk.com');
echo $html1;
-----------------------------
The same problem occurs again when i use in object oriented way.

Works:

Code: Select all

$html1 = new simple_html_dom();
$address1='http://www.yahoo.com';
$html1->load_file($address1);
echo "$html1";
Doesn't work:

Code: Select all

$html2 = new simple_html_dom();
$address2='http://www.eksisozluk.com';
$html2->load_file($address2);
echo "$html2";

The error is:

Warning: file_get_contents(http://www.eksisozluk.com) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/mysite/public_html/myfolder/simple_html_dom.php on line 850

Fatal error: Call to a member function innertext() on a non-object in /home/mysite/public_html/myfolder/simple_html_dom.php on line 1364

Re: file_get_html error on one site

Posted: Sat Sep 03, 2011 12:20 pm
by ok
Some web hosting companies block certain PHP functions. They might also block certain sites.

What hosting company do you use? Is it free hosting?

Try to contact the hosting company to check if the problem comes from their end.

Re: file_get_html error on one site

Posted: Sat Sep 03, 2011 12:31 pm
by mavera2
The interesting point is,
when i used free hosting the code was working,
when i bought a hosting account from different company the code didn't work.

I send a ticket to company, waiting for reply.

Re: file_get_html error on one site

Posted: Sat Sep 03, 2011 12:38 pm
by mavera2
Another interesting thing is this code also works:

Code: Select all

echo '<iframe id="id1" name="name1" class="iframe1" src="http://www.eksisozluk.com"></iframe>';
So didn't they block the site??

Re: file_get_html error on one site

Posted: Sat Sep 03, 2011 12:43 pm
by ok
If you use iframe, the user's is loading the external site, but if you use PHP, you are the one who is loading the external site.

Re: file_get_html error on one site

Posted: Sat Sep 03, 2011 12:57 pm
by mavera2
ok wrote:If you use iframe, the user's is loading the external site, but if you use PHP, you are the one who is loading the external site.
dear ok,
while waiting for company's reply is there any other way/function call to check if they blocked it?