Jump to content

file_get_html error on one site


mavera2

Recommended Posts

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:

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:

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:

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

 

Doesn't work:

$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

Link to comment
Share on other sites

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

 

You may need to check and make sure your host has fopen wrappers enabled.

Link to comment
Share on other sites

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

 

You may need to check and make sure your host has fopen wrappers enabled.

 

As far as i found from google search i run this script.

 

if( ini_get('allow_url_fopen') ) {
echo "allo url fopen is OK";
}
else {
echo "allo url fopen is NOT OK";
}

 

It gave the result OK.

Link to comment
Share on other sites

Sometimes the http:// protocol will fail because sites require that a user_agent exist.  Since PHP defines this user_agent string as empty, then you would need to make sure it is populated.

 

; Define the User-Agent string. PHP's default setting for this is empty.

; http://php.net/user-agent

;user_agent="PHP"

 

dear jcbones,

that really helped me much :) :) :)

thank you very much :)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.