php-simple-html-dom-parser icon indicating copy to clipboard operation
php-simple-html-dom-parser copied to clipboard

Warning: file_get_contents(): stream does not support seeking

Open avecNava opened this issue 8 years ago • 7 comments

I have been experiencing the error "Warning: file_get_contents(): stream does not support seeking..." since I upgraded to PHP 7.1.x

Any fixes ?

avecNava avatar Mar 23 '17 02:03 avecNava

https://github.com/sunra/php-simple-html-dom-parser/issues/11#issuecomment-61868883

sunra avatar Mar 24 '17 08:03 sunra

quick fix:

$curl = curl_init();
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_URL, "http://example.com");
$html=curl_exec($curl);
$dom = new simple_html_dom(null, true, true, DEFAULT_TARGET_CHARSET, true, DEFAULT_BR_TEXT, DEFAULT_SPAN_TEXT);
$html=$dom->load($html, true, true);

nekromoff avatar Apr 06 '17 22:04 nekromoff

In PHP 7.1, "Support for negative offsets has been added." to file_get_contents().

Change $offset = -1 by $offset = 0 in the simple_html_dom.php file:

function file_get_html($url, $use_include_path = false, $context=null, $offset = 0, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)

coudrak avatar Aug 04 '17 04:08 coudrak

@coudrak Thanks a lot

Elessar1986 avatar Oct 12 '17 18:10 Elessar1986

@coudrak Thanks a lot

tianyingzhong avatar Dec 09 '18 09:12 tianyingzhong

HI dear's sir i'm using simple php dom but now im facing error, cloudflar security google recapcha , please help me how to fix this, thanks "Attention Required! | Cloudflare"

adeelbhatti4454 avatar May 02 '19 14:05 adeelbhatti4454

quick fix:

$curl = curl_init();
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_URL, "http://example.com");
$html=curl_exec($curl);
$dom = new simple_html_dom(null, true, true, DEFAULT_TARGET_CHARSET, true, DEFAULT_BR_TEXT, DEFAULT_SPAN_TEXT);
$html=$dom->load($html, true, true);

HI dear's sir i'm using your simple php dom but now im facing error, cloudflar security google recapcha , please help me how to fix this, thanks "Attention Required! | Cloudflare"

adeelbhatti4454 avatar May 02 '19 14:05 adeelbhatti4454