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.

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

报告相同问题?

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳