搜索引擎收录推送工具 - 一键提交网站链接提升排名
<div class='container'>
<h1>搜索引擎收录推送工具</h1>
<form>
<input type='text' id='url' placeholder='请输入网址,支持http和https'>
<button type='button' id='submit_single'>单链接推送</button>
<button type='button' id='submit_all'>全站链接采集</button>
</form>
<div class='result'>
<h2>采集结果</h2>
<ul id='result_list'></ul>
<button type='button' id='submit_all_push'>提交全站链接推送</button>
</div>
<div class='success' id='success'>推送成功!</div>
<div class='error' id='error'>推送失败,请检查输入的网址!</div>
</div>
<script>
var submit_single = document.getElementById('submit_single');
var submit_all = document.getElementById('submit_all');
var submit_all_push = document.getElementById('submit_all_push');
var result = document.querySelector('.result');
var result_list = document.getElementById('result_list');
var success = document.getElementById('success');
var error = document.getElementById('error');
<p>submit_single.addEventListener('click', function() {
var url = document.getElementById('url').value;
if(url) {
pushSingle(url);
} else {
alert('请输入网址!');
}
});</p>
<p>submit_all.addEventListener('click', function() {
var url = document.getElementById('url').value;
if(url) {
collectAll(url);
} else {
alert('请输入网址!');
}
});</p>
<p>submit_all_push.addEventListener('click', function() {
pushAll();
});</p>
<p>function pushSingle(url) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'push.php', true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
if(xhr.responseText == 'success') {
showSuccess();
} else {
showError();
}
}
};
xhr.send('url=' + encodeURIComponent(url));
}</p>
<p>function collectAll(url) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'collect.php', true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
var response = JSON.parse(xhr.responseText);
if(response.length > 0) {
showResult(response);
} else {
alert('没有采集到链接!可能是因为输入的网址不正确或者网站没有可采集的链接。建议检查输入的网址是否正确,并确保网站有可采集的链接。');
}
}
};
xhr.send('url=' + encodeURIComponent(url));
}</p>
<p>function pushAll() {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'push.php', true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
if(xhr.responseText == 'success') {
showSuccess();
} else {
showError();
}
}
};
xhr.send('url=all');
}</p>
<p>function showResult(result) {
result_list.innerHTML = '';
for(var i = 0; i < result.length && i < 100; i++) {
result_list.innerHTML += '<li>' + result[i] + '</li>';
}
result.style.display = 'block';
}</p>
<p>function showSuccess() {
success.style.display = 'block';
setTimeout(function() {
success.style.display = 'none';
}, 3000);
}</p>
<p>function showError() {
error.style.display = 'block';
setTimeout(function() {
error.style.display = 'none';
}, 3000);
}
</script></p>
原文地址: https://www.cveoy.top/t/topic/mrCy 著作权归作者所有。请勿转载和采集!