ホームページ  >  記事  >  バックエンド開発  >  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 までご連絡ください。