dongyong8071 2013-10-09 22:11
浏览 24
已采纳

简单的html dom - 比预期的其他结果

I try to retrieve info from a webpage using simple_html_dom, like this:

<?PHP
include_once('dom/simple_html_dom.php');
$urlpart="http://w2.brreg.no/motorvogn/";
$url = "http://w2.brreg.no/motorvogn/heftelser_motorvogn.jsp?regnr=BR15597";
$html = file_get_html($url);

foreach($html->find('a') as $element) 
       if(preg_match('*dagb*',$element)) {
       $result=$urlpart.$element->href;

       $resultcontent=file_get_contents($result);
       echo $resultcontent;

       }

?>

The $result variable first gives me this URL: http://w2.brreg.no/motorvogn/dagbokutskrift.jsp?dgbnr=2011365320&embnr=0&regnr=BR15597

When accessing the above URL with my browser, i get the content i expect.

When retrieving the content with $resultcontent, i get a different result, where it says in norwegian "Invalid input".

Any ideas why?

  • 写回答

2条回答 默认 最新

  • droe9376 2013-10-11 10:30
    关注
    foreach($html->find('a') as $element) 
           if(preg_match('*dagb*',$element)) {
           $result=$urlpart.$element->href;
           $resultcontent=file_get_contents(html_entity_decode($result));
           echo $resultcontent;
    
           }
    

    This should do the trick.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教