繁体   English   中英

cURL PHP内部错误,为什么?

[英]cURL PHP Internal Error, why?

我正在使用一种工具来从包含特定网址的Google搜索中获取网址。 输入是URL列表和目标URL,所需的输出是在包含目标URL的列表中的那些搜索中显示的广告的URL列表。 Curl用于获取这些搜索的源代码。

该程序位于http://obsidianpunch.com/Summer,但是您可以看到它返回了内部服务器错误。 “搜索”是google搜索网址,输入字段代理和竞争无处可去。

不幸的是,GoDaddy不允许我查看错误日志,尽管我希望很快能收到他们的客户支持的回音...

我已经三重检查了数据库的详细信息,并且正在寻找会导致此错误的代码中的错误。

Google广告的分隔符可能已关闭,但我不希望这会导致空白结果而不是错误。

任何解决这种僵局的建议都值得赞赏。 谢谢。

<html>
<body>

<?
set_time_limit (0);

$urls=explode("\n", $_POST['url']);

$target=$_Post['target'];

$allurls=count($urls);

//use the new tool box
require "ToolBoxA4.php";

for ( $counter = 0; $counter <= $allurls; $counter++) {


 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL,$urls[$counter]);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'GET');
 curl_setopt ($ch, CURLOPT_HEADER, 1); 
 curl_exec ($ch); 
 $curl_scraped_page=curl_exec($ch); 



//call the new function parseA1
$arrOut = parseA1 ($curl_scraped_page);

//the output is an array with 3 items:  $arrOut[0] is RHS, $arrOut[1] is TOP, $arrOut[2] is NAT
//to look at the RHS

$curl_scraped_page=strtolower($curl_scraped_page);
$haystack=$curl_scraped_page;
if (strlen(strstr($haystack,$target))>0) {



$FileName = abs(rand(0,1000000000000));
$FileHandle = fopen($FileName, 'w') or die("can't open file");
fwrite($FileHandle, $curl_scraped_page);

$hostname="********.hostedresource.com";
$username="*******";
$password="*******";
$dbname="******";
$usertable="*******";

$con=mysql_connect($hostname,$username, $password) or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>");
mysql_select_db($dbname ,$con);

$right = explode(",", $arrOut[0]);
$top = explode(",", $arrOut[1]);

for ( $countforme = 0; $countforme <= 5; $countforme++) {

$topnow=$top[$countforme];

$query = "INSERT INTO ***** (time, ad1) VALUES ('$FileName','$topnow')";
mysql_query($query) or die('Error, insert query failed');

}

for ( $countforme = 0; $countforme <= 15; $countforme++) {

$rightnow = $right[$countforme];


$query = "INSERT INTO ***** (time, ad1) VALUES ('$FileName','$rightnow')";
mysql_query($query) or die('Error, insert query failed');

}

mysql_close($con);

echo 'Done';


fclose($FileHandle);
}
curl_close($ch);

}



?>

</body>
</html>

这是上面所说的toolboxA4.php。

<?php

function strTrim ($strIn, $cutA, $cutB){
    //keeps what is between $cutA and $cutB
    $pieces = explode($cutA, $strIn, 2);
    $str1 = $pieces[1];  //keep everything after cutA 

    $pieces = explode($cutB, $str1, 2);
    $strOut = $pieces[0];  //keep everything before cutB            
    return $strOut;
}

function arrWords ($strIn, $theStart, $theEnd){
    //returns what is between $theStart and $theEnd
    $cutA = $theStart;
    $pieces = explode($cutA, $strIn);
    $pieces[0] = "";  //discard the first piece

    $cutB = $theEnd;
    foreach ($pieces as $key => $value) {
        $arrB = explode($cutB, $value, 2);
        $arrOut[$key] = $arrB[0];  //keep everything before cutB        
    }

    return $arrOut;
}

function arrElems ($strIn, $tag){
    //returns what is between <$tag> and </$tag>
    $cutA = "<$tag>";
    $pieces = explode($cutA, $strIn);
    $pieces[0] = "";  //discard the first piece

POST数组区分大小写,因此从更改开始

$target=$_Post['target'];
 $target=$_POST['target']; 

是否启用了短标签

超全局 $_POST应该全部大写。

http://php.net/manual/en/reserved.variables.post.php

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM