由于业务需要在微信推广,在推广前域名检测已是常规操作,链接多一个一个检测太麻烦,开发批量检测就很方便。作为一名程序猿熊熊燃气,批量检测比单个检测方便、快速,同理技术实现也会有难度,好在开发完成,现在分享给大家。
api对接实现代码
<!--api对接组件 -->
<div class="panel" style="background:#0f8ee7">
<div class="panel_inner">
<div class="promo">
<!--标题 -->
<h2 style="color:#fff">微信域名批量检测</h2>
</div>
<div class="form1">
<!--输入框,可自己调节大小 -->
<textarea class="main-textarea" placeholder="请输入需要检测的链接,一行一个" type="text" id="text" name="text" value="" size="20" style="height:360px;width:100%"></textarea>
<!--提交 -->
<button type="button" id="btn-tcn" class="main-button" onclick="wxcheck_form()">批量检测</button>
</div>
<!--输出结果 -->
<div id="result_panel"></div>
</div>
</div>
js调用代码
<script src="http://juhecdn.oss-cn-hangzhou.aliyuncs.com/jquery/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://yunapposs.oss-cn-hangzhou.aliyuncs.com/static/web/layer3/layer.js" charset="utf-8"></script>
主方法实现代码
<script>
var notice_msg = '微信域名检测';
var api_host = 'http://api.new.urlzt.com/api/vx';
function wxcheck_form(){
$("#result_panel").hide();
var url_longs = $("#text").val();
if(!url_longs) {
alert('输入格式不正确!');
return false;
}
$.post(api_host+"/"+"wxcheck/web_panel", {url_longs:url_longs},function(result){
$('#result_panel').html(result);
$("#result_panel").show();
wxcheck_handdle();
});
return false;
}
function wxcheck_handdle() {
var wxcheck_api_url = 'http://api.new.urlzt.com/api/vx?token=Token值(后台生成获取)&url=';//检测接口,后台地址:https://dwz.cn/TzLUYNU2
var em = $("*[data='-']:eq(0)");
if(em.length>0) {
em.attr('data','loading');
em.html('<img src="https://tigimg-1252093452.image.myqcloud.com/2020/04/22/i15fEBcCzV7lpvOjyLfX.gif" />');
$.get(wxcheck_api_url+em.attr('url-long'),function(result){
if(result.indexOf('正常')>-1) {
em.html('<span class="opt-result-ok" style="color:green;">域名正常</span>');
wxcheck_handdle();
} else if(result.indexOf('被封')>-1) {
em.html('<span class="opt-result-fail">域名被封</span>');
wxcheck_handdle();
} else if(result.indexOf('异常,查看原因')>-1) {
em.html('<span class="opt-result-fail">接口到期,点击:<a href="http://www.urlzt.com">www.urlzt.com</a>查看原因</span>');
wxcheck_handdle();
} else {
em.html('<span class="opt-result-fail">'+result+'</span>');
wxcheck_handdle();
}
});
}
}
</script>
完整接口html代码
下载及说明地址:https://fqlq4dbcak.feishu.cn/docs/doccnUa4D9GT4eHFiSBNrKStXUd
<!DOCTYPE html>
<html>
<head>
<title>微信域名批量检测</title>
<meta name="keywords" content="{{=it.site.widgets.seo_keywords}}">
<meta name="description" content="{{=it.site.widgets.seo_description}}" >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="applicable-device" content="pc,mobile">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="baidu-site-verification" content="{{=it.site.widgets.baidutj_verification}}">
<link rel="shortcut icon" href="{{=it.site.widgets.favicon}}">
<link type="text/css" rel="stylesheet" href="http://templ1.oss-cn-hangzhou.aliyuncs.com/ailu/ailu_style_wxcheck.css" media="all" />
<link rel="stylesheet" type="text/css" href="https://templ1.oss-cn-hangzhou.aliyuncs.com/ailu/ailu_base.css">
<link rel="stylesheet" type="text/css" href="http://templ1.oss-cn-hangzhou.aliyuncs.com/ailu/ailu_style.css">
</head>
<body>
<!--api对接组件 -->
<div class="panel" style="background:#0f8ee7">
<div class="panel_inner">
<div class="promo">
<!--标题 -->
<h2 style="color:#fff">微信域名批量检测</h2>
</div>
<div class="form1">
<!--输入框,可自己调节大小 -->
<textarea class="main-textarea" placeholder="请输入需要检测的链接,一行一个" type="text" id="text" name="text" value="" size="20" style="height:360px;width:100%"></textarea>
<!--提交 -->
<button type="button" id="btn-tcn" class="main-button" onclick="wxcheck_form()">批量检测</button>
</div>
<!--输出结果 -->
<div id="result_panel"></div>
</div>
</div>
<script src="http://juhecdn.oss-cn-hangzhou.aliyuncs.com/jquery/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://yunapposs.oss-cn-hangzhou.aliyuncs.com/static/web/layer3/layer.js" charset="utf-8"></script>
<script>
var notice_msg = '微信域名检测';
var api_host = 'http://api.new.urlzt.com/api/vx';
function wxcheck_form(){
$("#result_panel").hide();
var url_longs = $("#text").val();
if(!url_longs) {
alert('输入格式不正确!');
return false;
}
$.post(api_host+"/"+"wxcheck/web_panel", {url_longs:url_longs},function(result){
$('#result_panel').html(result);
$("#result_panel").show();
wxcheck_handdle();
});
return false;
}
function wxcheck_handdle() {
var wxcheck_api_url = 'http://api.new.urlzt.com/api/vx?token=Token值(后台生成获取)&url=';//检测接口,后台地址:https://dwz.cn/TzLUYNU2
var em = $("*[data='-']:eq(0)");
if(em.length>0) {
em.attr('data','loading');
em.html('<img src="https://tigimg-1252093452.image.myqcloud.com/2020/04/22/i15fEBcCzV7lpvOjyLfX.gif" />');
$.get(wxcheck_api_url+em.attr('url-long'),function(result){
if(result.indexOf('正常')>-1) {
em.html('<span class="opt-result-ok" style="color:green;">域名正常</span>');
wxcheck_handdle();
} else if(result.indexOf('被封')>-1) {
em.html('<span class="opt-result-fail">域名被封</span>');
wxcheck_handdle();
} else if(result.indexOf('异常,查看原因')>-1) {
em.html('<span class="opt-result-fail">接口到期,点击:<a href="http://www.urlzt.com">www.urlzt.com</a>查看原因</span>');
wxcheck_handdle();
} else {
em.html('<span class="opt-result-fail">'+result+'</span>');
wxcheck_handdle();
}
});
}
}
</script>
</body>
</html>