dongzaheng4449 2016-02-12 15:21
浏览 90
已采纳

File_get_html在PHP Simple HTML DOM Parser中返回空的html

I made a script that was getting content from another site using Simple HTML DOM Parser. It looked like this

include_once('simple_html_dom.php');

$html = file_get_html('http://csgolounge.com/'.$tradeid);       

foreach($html->find('div[id=tradediv]') as $trade) {
    $when = $trade->find('.tradeheader')[0];
 }

I was probably looking for content too often (every 30 secs) , and now i get empty html back.

I tryed to change User agent like this

$context = stream_context_create();
stream_context_set_params($context, array('user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6
'));
$html = file_get_html('http://csgolounge.com/profile?id='.$steamid, 0, $context);

But am still getting back empty html.

  • 写回答

1条回答 默认 最新

  • duanjiu6697 2016-02-12 22:53
    关注

    The problem was that my html file was too big . Simple html dom has defined max file size define('MAX_FILE_SIZE', 600000). I changed it to 900000 and now its working again.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?