PHP生成随机网址并批量提交百度

代码 2019-10-05 22:05:58

方法一:

<?php
function randKey($len) 
{
	$chars = array( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
	$charsLen = count($chars) - 1;
	shuffle($chars);
	$str = "";
	for ($i=0; $i<$len; $i++) 
	{
		$str .= $chars[mt_rand(0, $charsLen)];
	}
	return $str;
}

for ($i = 0; $i < 20; $i++) {
	 $url.= "http://".$_SERVER['HTTP_HOST']."/".randKey(7)."/<br>";
}

$urls = explode("<br>",$url);
$urls=array_diff($urls,array(NULL));
$api = 'http://data.zz.baidu.com/urls?site='.$yuming[1].'&token=NlsJKAy95ysMnLUA';
$ch = curl_init();
$options =  array(
    CURLOPT_URL => $api,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => implode("\n", $urls),
    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;
?>

方法二:

<?php
$yuming = "
www.huaianseo.cn
";
$yuming = explode(PHP_EOL,$yuming);
$yuming=array_diff($yuming,array(NULL));
shuffle($yuming); 
$str = "0123456789abcdefghijklmnopqrstuvwxyz";//输出字符集
$n = 7;//输出串长度
$len = strlen($str)-1;
for($j=0 ; $j<2000 ; $j++){
  for($i=0 ; $i<$n; $i++){
    $s .= $str[rand(0,$len)];
    $s1 .= $str[rand(0,$len)];
  }
  $url.= 'http://'.$yuming[1].'/'.$s1.'/<br>';
  $s = "";
  $s1 = "";
}
//print_r($url);
$urls = explode("<br>",$url);
$urls=array_diff($urls,array(NULL));
//print_r($urls);
$api = 'http://data.zz.baidu.com/urls?site='.$yuming[1].'&token=NlsJKAy95ysMnLUA';
$ch = curl_init();
$options =  array(
    CURLOPT_URL => $api,
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => implode("\n", $urls),
    CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;
?>

评论

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!