ZIP免费源码小插件-查询网站备案代码.zip 2.15KB

weixin_60708128

资源文件列表:

ba.zip 大约有1个文件
  1. ba.php 5.54KB

资源介绍:

最近在开发一个插件,其中有个很重要的功能就是查询对象网站是否备案。我在网上找了一圈,发现好多能实现这个功能的接口都是要收费的。咱就是说,能不花钱就不花钱,本着能省尽省的原则,我开始努力地寻找免费的接口。 还真别说,经过一番折腾,我找到了几个还算不错的免费接口。我把这几个接口整合到一起,采用随机匹配的方式。这样一来,如果一个接口失效了,就会自动切换到下一个接口,一直到成功查询出结果为止。虽然过程有点曲折,但总算是解决了这个问题,下面我把代码放出,有需要的自取吧 ————————————————
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> body { font-family: Arial, sans-serif; background-color: #f5f5f5; padding: 10px; } input[type="text"] { padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 5px; width: 100%; box-sizing: border-box; } button { padding: 10px 20px; font-size: 16px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; width: 100%; box-sizing: border-box; margin-top: 10px; } .result { margin-top: 20px; padding: 15px; background-color: white; border: 1px solid #ccc; border-radius: 5px; } .result p { margin: 5px 0; } </style> <script> // 页面加载时检查 URL 参数并自动查询 window.onload = function () { const urlParams = new URLSearchParams(window.location.search); let domain = urlParams.get('domain'); if (domain) { checkDomain(domain); } }; // 绑定回车键按下事件 document.addEventListener('keydown', function (event) { if (event.key === 'Enter') { checkDomain(); } }); function checkDomain(domainFromInput = null) { let domain; if (domainFromInput) { domain = domainFromInput; } else { domain = document.getElementById('domainInput').value; } if (!isCorrectDomain(domain)) { document.querySelector('.result').innerHTML = "输入的不是正确的网址格式"; return; } document.querySelector('.result').innerHTML = "正在查询中..."; let urls = [ { url: "https://api.leafone.cn/api/icp?name=" + domain, number: 1 }, { url: "https://cn.apihz.cn/api/wangzhan/icp.php?id=10000963&key=7a25e0fbd6ffbe24729dfa6e364adc56&domain=" + domain, number: 2 },//注意此处id和key请修改为你自己的,可在网站免费申请 { url: "https://api.muxiuge.com/api/beian/?domain=" + domain, number: 3 } ]; let success = false; urls.sort(() => Math.random() - 0.5); let remainingUrls = urls.length; urls.forEach(({ url, number }, index) => { fetch(url) .then(response => response.json()) .then(responseData => { if ((responseData.code === 200 || responseData.success === true) && (!responseData.icp || responseData.icp!== '查询失败')) { success = true; let resultHtml = ""; switch (number) { case 1: resultHtml += `<p>来自编号 1 接口:</p> <p>网址:${responseData.data.list[0].domain}</p> <p>名称:${responseData.data.list[0].unitName}</p><p>备案号:${responseData.data.list[0].serviceLicence}</p>`; break; case 2: resultHtml += `<p>来自编号 2 接口:</p><p>名称:${responseData.unit}</p><p>备案号:${responseData.icp}</p>`; break; case 3: resultHtml += `<p>来自编号 3 接口:</p><p>网址:${responseData.result.domain}</p><p>名称:${responseData.result.name}</p><p>备案号:${responseData.result.icp}</p>`; break; } document.querySelector('.result').innerHTML = resultHtml; return; } else { remainingUrls--; if (remainingUrls === 0 &&!success) { document.querySelector('.result').innerHTML = "网址:"; document.querySelector('.result').innerHTML += domain + " <br>未查询到备案信息!"; } } }) .catch(error => { remainingUrls--; if (remainingUrls === 0 &&!success) { document.querySelector('.result').innerHTML = "网址:"; document.querySelector('.result').innerHTML += domain + " <br>未查询到备案信息!"; } }); }); } function isCorrectDomain(domain) { let parts = domain.split('.'); let suffix = parts[parts.length - 1]; if (/\d/.test(suffix)) { return false; } if (!/^(https?:\/\/)?([\da-z\.-]+)\.([a-zA-Z]{2,6}|商城|中国|网络|公司)([\/\w \.-]*)*\/?$/.test(domain)) { return false; } let validTlds = [ 'com', 'net', 'org', 'cn', 'la', 'biz', 'info', 'me', 'name', 'pro', 'mobi', 'tel', 'tv', 'co', 'cc', 'xyz', 'top', 'club', 'online', 'site', 'store', 'tech', 'party', 'link', 'edu', 'gov', 'mil', 'int', 'ac', 'io', 'ai', 'ws', 'asia', 'cat', 'jobs', 'aero', 'coop', 'museum', 'travel', 'art', 'vip', 'blog', 'design', 'graphics', 'host', 'security', 'software', 'systems', 'foundation', 'network', 'space', 'wiki', 'work' ]; if (!validTlds.includes(suffix) &&!['商城', '中国', '网络', '公司'].includes(suffix)) { return false; } return true; } </script> </head> <body> <div class="input-container"> <input type="text" id="domainInput" placeholder="请输入域名"> <button onclick="checkDomain()">查询</button> </div> <div class="result">请输入域名查询备案信息</div> </body> </html>
100+评论
captcha
    类型标题大小时间
    ZIP 1.使用scikit-learn(GridSearchCV)进行网格搜索超参数调整(Python代码,包括数据集)52.98MB7月前
    ZIP2.使用scikit-learn和Python进行超参数调整(Python代码,包括数据集)148.73KB7月前
    ZIPCSDN新客户端.zip22.79MB7月前
    ZIPstylus-1.5.51.zip1.35MB7月前
    ZIPArduino-INA226-程序922.46KB7月前
    ZIP【Babylon提升】加载wms瓦片地图4.72KB7月前
    ZIPMarvell SWdownloader 4.8.8.228.6MB7月前
    ZIP起床战争服务端(来源:B站@73m9)89.98MB7月前