failed to open stream: HTTP request failed!
Warning: file_get_contents(http://wenwen.soso.com/) : failed to open stream: HTTP request failed! in D:\wwwroot\www\wuduyehua.com\index.php on line 27源码:
<?php
$site= new stdClass;
sscanf($_SERVER['REQUEST_URI'], str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']).'%s', $site->req_part);
$site->doc_root = dirname(__FILE__);
$site->req_root = $site->web_root = in_array(dirname($_SERVER['SCRIPT_NAME']), array('/', '\\')) ? '' : dirname($_SERVER['SCRIPT_NAME']);
$site->req_host = strtolower($_SERVER['HTTP_HOST']);
@set_magic_quotes_runtime(0);
$conf = include $site->doc_root.'/config.php';
include $site->doc_root.'/inc/simple_html_dom.php';
###########################
$site->req_part = str_replace('.html', '.htm', $site->req_part);
$a = array(
'.htm' => '.html',
'z/' => 'news/',
);
$site->req_part = strtr($site->req_part, array_flip($a));
$site->is_front = (($site->req_part == 'index.php') or empty($site->req_part));
$c = file_get_contents(str_replace('index.php?','z/','http://wenwen.soso.com/'.($site->is_front ? '' : $site->req_part)));
for($i=0;$i<100;$i++){
$getpage = @file_get_contents($Url);
if($getpage) break;
}
###########################
$p = array(
'#<span style="float:right">.+?</span>#si',
);
$c = preg_replace($p, '', $c);
###########################
$p = array(
's_base_grey.css',
'--腾讯旗下互动问答社区',
'favicon.ico',
);
$c = str_replace($p, '', $c);
###########################
$a = array(
'.htm' => '.html',
'http://cache.soso.com/wenwen/i/' => '/img/',
'/z/' => '/news/',
'<input type="hidden" name="sp"' => '<input type="hidden" name="assd"',
'maxlength="100" name="w"' => 'maxlength="100" name="sp"',
'搜搜问问' => $conf['name'],
);
$c = strtr($c, $a);
###########################
$d = str_get_html($c);
$a = array(
'#s_nav',
'#s_copyright',
'#banner',
'.category_con .search',
'#s_feeds',
'#topLeft',
'#s_service',
'#s_footer .links',
'#bbs',
'*' => 'script',
'.answer_question',
'a[.style3]',
'.operation',
'#summary',
);
rm($a);
###########################
$a = array('onkeyup', 'onkeydown', 'onclick', 'onload', 'onmouseover', 'onsubmit');
foreach($a as $v){
if($a = $d->find("[{$v}]")){
foreach($a as $e){
$e->$v = null;
}
}
}
###########################
if($e = $d->find('#right', 0)){
$e->innertext = adv('right');
}
if($e = $d->find('.column2', 0)){
$e->innertext = adv('right');
}
if($e = $d->find('#nav', 0)){
$e->outertext = adv('nav');
}
if($e = $d->find('#s_footer', 0)){
$e->innertext = adv('foot');
}
if($e = $d->find('#answerQuestionDiv', 0)){
$e->innertext = adv('post');
}
###########################
if($a = $d->find('a')){
foreach($a as $e){
$e->outertext = $e->innertext;
}
}
if($e = $d->find('', 0)){
$e->action = '/news/Search.e';
}
if($e = $d->find('meta', 0)){
$e->content = $conf['word'];
}
if($e = $d->find('meta', 0)){
$e->content = $conf['desc'];
}
###########################
print($d);
###########################
function rm($a){
global $d;
foreach($a as $v){
$k = 0;
if(is_array($v)){
$k = key($v);
$v = $v[$k];
}
if($k == '*'){
if($a = $d->find($v)){
foreach($a as $e){
$e->outertext = '';
}
}
continue;
}
if($e = $d->find($v, $k)){
$e->outertext = '';
}
}
}
function adv($pos){
global $site;
return file_get_contents($site->doc_root.'/adv/'.$pos.'.txt');
}
请问怎么改成CURL方法抓取不会出错 有懂的没有。在问问。
页:
[1]