Warning: file_get_contents(http://www.xxx.com/) [function.file-get-contents]: failed to open stream: HTTP request failed! in D:\wwwroot\www.xxxx.com\class.php on line 17
为避免AD嫌疑,网址全部改为www.xxx.com
有人说用curl_setop函数好些,我想请问怎么改?代码如下:
<?
require("config.php"); 
$opts = array(
  'http'=>array(
    'method'=>"GET",
    'timeout'=>60,
   )
);
$context = stream_context_create($opts);//设置超时;用于解决连接超时的问题
$id=$_GET["id"];
$lm=$_GET["lm"];
$pn=$_GET["pn"];
if ($id===''){
header("refresh:0;url=index.php"); 
}else{
$url='http://www.xxx.com/'.$id.'?lm='.$lm.'&pn='.$pn;
$temp=file_get_contents($url, false, $context);
$start='我不不不_';
$end='</title>';
$title= intercept_str($temp,$start,$end,1);
//preg_match_all('/\<span id\="reply_content(.*)<\/pre><\/cn><\/span>/', $temp,$answer);
//preg_match_all('/(<pre>)+[^<>]+(<\/pre>)+/',$temp,$answer);
preg_match_all("'<pre>(.*)</pre>'isU",$temp,$answer);