我前两天写了个采集,用的file_get_contents,一切正常。今天早上,我突然发现有一个网站采集不了了我没有改动代码,采集规则也没有变我在本地测试,结果能够采集,但是在VPS里面就不能采集了我以为是服务器的IP被那个网站封了,于是我用远程进入到服务器里面,结果在服务器里面又能登录那个网站,浏览一切正常。但是唯独就是采集不了
怎么回事啊?代码如下:
if(!isset($_POST["action"]) or $_POST["action"]==""){
$action="Null";
}else{
$action=$_POST["action"];
}
if($action=="save"){
if(!isset($_POST["url"]) or $_POST["url"]==""){
echo "请填写地址!<br/>";
$url="";
}else{
$url=$_POST["url"];
if(substr($url,0,7)!="http://"){
$url="http://".$url;
}
if(!isset($_POST["types"]) or $_POST["types"]==""){
$types=0;
}else{
$types=$_POST["types"];
}
if(!isset($_POST["where"]) or $_POST["where"]==""){
$where=0;
}else{
$where=$_POST["where"];
}
if(!isset($_POST["css"]) or $_POST["css"]==""){
$css=0;
}else{
$css=$_POST["css"];
}
@$result=file_get_contents($url);
if($result){
$txt=$utf8->utf8($result);
if($where==1){
if($css==1){
$txt=str_replace("///","<br/>",$txt);
}else{
$txt=str_replace("///","\r\n",$txt);
}
if($types==1){
$txt=str_replace("<br/>","<br/>",$txt);
}
echo $txt;
}else{
if($css==1){
$txt=str_replace("///","\r\n",$txt);
}else{
$txt=str_replace("///","",$txt);
}
if($types==1){
$txt=str_replace("<br/>","\r\n",$txt);
}
echo "<textarea name='' style='width:100%' rows='7'>".$txt."</textarea><br/>";
}
$urls=str_replace("&","@@",$url);
echo "<div class='topic_xinxi'>
<form action='/tools/tou_down2.php?action=save&url=$urls&sid=$GLOBALS[sid]' method='post'>
<input type='submit' name='button' id='button' value='下载为TXT'/>
</form>
</div>";
}else{
echo "源代码偷窥失败啦!<br/>";
}
}}else{
echo "强大的源码查看器,可以无忧地查看任何页面的源码(包括电脑页面),多种模式供您选择,如果你需要复制,请选择显示在文本框内;如果你怕浪费流量,请选择揉成一团。";
$url="";
}
echo "<div class='topic_xinxi'>";
echo "<form action='/?cmd=t101&sid=$GLOBALS[sid]' method='post'>";
echo "页面的地址(选填http://):<br/>";
echo "<input type='text' name='url' size='12' maxlength='300' value='$url'/><br/>";
echo "CSS显示(不含页面):<br/>";
echo "<input type=\"radio\" name=\"css\" value='0' checked='checked'>揉成一团<br/>";
echo "<input type=\"radio\" name=\"css\" value='1'>分行清晰<br/>";
echo "页面代码(不含CSS):<br/>";
echo "<input type=\"radio\" name=\"types\" value='0'>揉成一团<br/>";
echo "<input type=\"radio\" name=\"types\" value='1' checked='checked'>分行清晰<br/>";
echo "显示在哪儿:<br/>";
echo "<input type=\"radio\" name=\"where\" value='0'>显示在文本框<br/>";
echo "<input type=\"radio\" name=\"where\" value='1' checked='checked'>显示在页面上<br/>";
echo "<input type='hidden' name='action' value='save' />";
echo "<INPUT type='image' src='img/but/up.png' alt='提交信息'>";
echo "</form>";
echo "</div>";
怎么回事啊?代码如下:
if(!isset($_POST["action"]) or $_POST["action"]==""){
$action="Null";
}else{
$action=$_POST["action"];
}
if($action=="save"){
if(!isset($_POST["url"]) or $_POST["url"]==""){
echo "请填写地址!<br/>";
$url="";
}else{
$url=$_POST["url"];
if(substr($url,0,7)!="http://"){
$url="http://".$url;
}
if(!isset($_POST["types"]) or $_POST["types"]==""){
$types=0;
}else{
$types=$_POST["types"];
}
if(!isset($_POST["where"]) or $_POST["where"]==""){
$where=0;
}else{
$where=$_POST["where"];
}
if(!isset($_POST["css"]) or $_POST["css"]==""){
$css=0;
}else{
$css=$_POST["css"];
}
@$result=file_get_contents($url);
if($result){
$txt=$utf8->utf8($result);
if($where==1){
if($css==1){
$txt=str_replace("///","<br/>",$txt);
}else{
$txt=str_replace("///","\r\n",$txt);
}
if($types==1){
$txt=str_replace("<br/>","<br/>",$txt);
}
echo $txt;
}else{
if($css==1){
$txt=str_replace("///","\r\n",$txt);
}else{
$txt=str_replace("///","",$txt);
}
if($types==1){
$txt=str_replace("<br/>","\r\n",$txt);
}
echo "<textarea name='' style='width:100%' rows='7'>".$txt."</textarea><br/>";
}
$urls=str_replace("&","@@",$url);
echo "<div class='topic_xinxi'>
<form action='/tools/tou_down2.php?action=save&url=$urls&sid=$GLOBALS[sid]' method='post'>
<input type='submit' name='button' id='button' value='下载为TXT'/>
</form>
</div>";
}else{
echo "源代码偷窥失败啦!<br/>";
}
}}else{
echo "强大的源码查看器,可以无忧地查看任何页面的源码(包括电脑页面),多种模式供您选择,如果你需要复制,请选择显示在文本框内;如果你怕浪费流量,请选择揉成一团。";
$url="";
}
echo "<div class='topic_xinxi'>";
echo "<form action='/?cmd=t101&sid=$GLOBALS[sid]' method='post'>";
echo "页面的地址(选填http://):<br/>";
echo "<input type='text' name='url' size='12' maxlength='300' value='$url'/><br/>";
echo "CSS显示(不含页面):<br/>";
echo "<input type=\"radio\" name=\"css\" value='0' checked='checked'>揉成一团<br/>";
echo "<input type=\"radio\" name=\"css\" value='1'>分行清晰<br/>";
echo "页面代码(不含CSS):<br/>";
echo "<input type=\"radio\" name=\"types\" value='0'>揉成一团<br/>";
echo "<input type=\"radio\" name=\"types\" value='1' checked='checked'>分行清晰<br/>";
echo "显示在哪儿:<br/>";
echo "<input type=\"radio\" name=\"where\" value='0'>显示在文本框<br/>";
echo "<input type=\"radio\" name=\"where\" value='1' checked='checked'>显示在页面上<br/>";
echo "<input type='hidden' name='action' value='save' />";
echo "<INPUT type='image' src='img/but/up.png' alt='提交信息'>";
echo "</form>";
echo "</div>";
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货