首页  >  文章  >  后端开发  >  php问题-PHP获取远程网页内容问题

php问题-PHP获取远程网页内容问题

WBOY
WBOY原创
2016-06-02 11:28:351330浏览

php问题php

分别用了curl和file_get_contents均无法获取到内容,替换网址后就可以了,具体如下:

<code><?phpfunction getwebcontent($url){    $ch = curl_init();    $timeout = 10;    curl_setopt($ch, CURLOPT_URL, $url);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);    $contents = trim(curl_exec($ch));    curl_close($ch);    return  $contents;} //$temps='http://127.0.0.1:50/admin/process_get.php?k=get&s=11&i=12367&url=www.100.com'; //$chS=file_get_contents($temps); $chS=getwebcontent('http://127.0.0.1:50/admin/process_get.php?k=get&s=11&i=12367&url=www.100.com'); echo $chS;?></code>

我的远程网址http://127.0.0.1:50/admin/process_get.php?k=get&s=11&i=12367&url=www.100.com 是可以访问的,内容为77788899

但通过curl和file_get_contents获取此网址均无法获取内容,导致服务器卡死,将上述网址替换为其他的网址,一切正常!!

老板说了,这个问题解决不掉,明天不让回家过年,请各位帮忙看看!!!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn