chstr php,php – str_get_html没有加载有效的html字符串

我使用curl收到一个html字符串:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$html_string = curl_exec($ch);

当我回应它时,我看到了一个非常好的HTML,因为我需要解析我的解析需求.

但是,当尝试将此字符串发送到HTML DOM PARSER方法str_get_html($html_string)时,它不会上传它(从方法调用返回false).

我尝试将其保存到文件并在文件上使用file_get_html打开,但同样的事情发生了.

这可能是什么原因?正如我所说,当我回应它时,html看起来非常好.

非常感谢.

代码本身:

$html = file_get_html("http://www.bgu.co.il/tremp.aspx");

$v = $html->find('input[id=__VIEWSTATE]');

$viewState = $v[0]->attr['value'];

$e = $html->find('input=[id=__EVENTVALIDATION]');

$event = $e[0]->attr['value'];

$html->clear();

unset($html);

$body = " A_STRING_THAT_CONTAINS_SOME_DATA "

$ch = curl_init("http://www.bgu.co.il/tremp.aspx");

curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$html_string = curl_exec($ch);

$file_handle = fopen("file.txt", "w");

fwrite($file_handle, $html_string);

fclose($file_handle);

curl_close($ch);

$html = str_get_html($html_string);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值