TypechoJoeTheme

从南小站-致我逝去的青春

统计
登录
用户名
密码

王从南

我將一直快樂並且永遠如此

查询百度收录子域名及收录量

2020-10-07
/
0 评论
/
96 阅读
/
正在检测是否收录...
10/07

简言

调用百度,查询该域名百度收录的子域名收录量

使用方法:http://域名/路径.php?url=查询域名

注:查询结果并不完全,只能获取百度收录的相关子域名,无相关收录的子域名并不能查询到。

返回样式为json格式。

PHP

<?php

$url=$_REQUEST["url"];

if(!$url){

exit(json_encode(array("code"=>1,"text"=>"请输入域名!"),320));

}

$data=json_decode(curl("http://ce.baidu.com/index/getRelatedSites?site_address=".$url),true);

if($data["code"]==10000){

exit(json_encode(array("code"=>2,"text"=>"域名输入错误!"),320));

}

if($data["code"]==0){

$array["code"]=200;

foreach($data["data"] as $v){

$array["domain"][]=$v["domain"];

$array["score"][]=$v["score"];

}

exit(json_encode($array,320));

}else{

exit(json_encode(array("code"=>3,"text"=>"查询失败!"),320));

}

function curl($url,$data=0,$header_array=0,$referer=0,$time=30,$code=0) {

    if($header_array==0) {

        $header=array("CLIENT-IP: ".getip_user(),"X-FORWARDED-FOR: ".getip_user(),'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36');

    } else {

        $header=array("CLIENT-IP: ".getip_user(),"X-FORWARDED-FOR: ".getip_user(),'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36');

        $header=array_merge($header_array,$header);

    }

//print_r($header);

    $curl=curl_init();

    curl_setopt($curl,CURLOPT_URL,$url);

    curl_setopt($curl,CURLOPT_HTTPHEADER,$header);

    if($data) {

        curl_setopt($curl,CURLOPT_POST,1);

        curl_setopt($curl,CURLOPT_POSTFIELDS,$data);

    }

    if($referer) {

        curl_setopt($curl,CURLOPT_REFERER,$referer);

    }

    curl_setopt($curl,CURLOPT_TIMEOUT,$time);

    curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1);

    curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);

    curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, FALSE);

    curl_setopt($curl,CURLOPT_SSL_VERIFYHOST, FALSE);

    curl_setopt($curl,CURLOPT_ENCODING,'gzip,deflate');

if($code) {

        curl_setopt($curl, CURLOPT_HEADER, 1);

        $return=curl_exec($curl);

        $code_code=curl_getinfo($curl);

        curl_close($curl);

        $code_int['exec']=substr($return,$code_code["header_size"]);

        $code_int['code']=$code_code["http_code"];

        $code_int['content_type']=$code_code["content_type"];

        $code_int['header']=substr($return,0,$code_code["header_size"]);

        return $code_int;

    } else {

        $return=curl_exec($curl);

        curl_close($curl);

        return $return;

    }

}

function getip_user() {

    if(empty($_SERVER["HTTP_CLIENT_IP"]) == false) {

        $cip = $_SERVER["HTTP_CLIENT_IP"];

    } else if(empty($_SERVER["HTTP_X_FORWARDED_FOR"]) == false) {

        $cip = $_SERVER["HTTP_X_FORWARDED_FOR"];

    } else if(empty($_SERVER["REMOTE_ADDR"]) == false) {

        $cip = $_SERVER["REMOTE_ADDR"];

    } else {

        $cip = "";

    }

    preg_match("/[\d\.]{7,15}/", $cip, $cips);

    $cip = isset($cips[0]) ? $cips[0] : "";

    unset($cips);

    return $cip;

}
PHP
朗读
赞(0)
赞赏
感谢您的支持,我会继续努力哒!

三合一收款

下面三种方式都支持哦

微信
QQ
支付宝
打开支付宝/微信/QQ扫一扫,即可进行扫码打赏哦
版权属于:

从南小站-致我逝去的青春

本文链接:

http://ouoo.fun/455.html(转载时请注明本文出处及文章链接)

评论 (0)