当我从网上看到SEO超级外链工具源码,试了试发现等他完成更新要很长时间,而且每天都要提交所以我写了SEO超级外链工具的api,通过宝塔的计划任务实现每天自动提交,我已经集成到当前源码里面了
//梦云博客www.0330.top
<?php
header('Content-type: application/json; charset=utf-8');
// 获取GET参数
$urlToCheck = $_GET['url'] ?? '';
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$linksFile = 'links.txt';
// 检查链接文件是否存在
if (!file_exists($linksFile)) {
echo json_encode(['error' => 'Links file not found.']);
exit;
}
// 读取链接文件
$links = file($linksFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if ($links === false) {
echo json_encode(['error' => 'Failed to read links file.']);
exit;
}
$totalLinks = count($links);
$perPage = 10; // 每页处理的链接数
$totalPages = ceil($totalLinks / $perPage); // 总页数
// 初始化成功计数器
$successCount = 0;
// 处理当前页面的链接
$start = ($page - 1) * $perPage;
$end = min($start + $perPage, $totalLinks);
$linksForCurrentPage = array_slice($links, $start, $perPage);
foreach ($linksForCurrentPage as $linkTemplate) {
// 替换模板中的占位符为实际的URL
$targetUrl = str_replace('***', $urlToCheck, $linkTemplate);
// 使用cURL发起HTTP请求
$ch = curl_init($targetUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 15); // 设置超时时间
curl_setopt($ch, CURLOPT_NOBODY, true); // 不需要body,只需要HTTP状态码
// 执行cURL请求
curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// 根据HTTP响应码计数成功或失败
if ($httpCode === 200) {
$successCount++;
}
}
// 输出当前页的处理结果
$result = [
'page' => $page,
'perPage' => $perPage,
'totalLinks' => $totalLinks,
'currentSuccessCount' => $successCount,
'totalSuccessCount' => $successCount,
'remainingPages' => $totalPages - $page
];
// 如果不是最后一页,添加下一页的URL
if ($page < $totalPages) {
// 生成下一页的URL
$nextPageUrl = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]&page=" . ($page + 1);
$result['nextPageUrl'] = $nextPageUrl;
} else {
// 这是最后一页,输出所有页面的处理结果
$result['totalSuccessCount'] = $successCount;
$result['remainingPages'] = 0;
}
echo json_encode($result);
#!/bin/bash
#将https://www.0330.top/seo/api.php?url=www.0330.top替换成你的api地址
#www.0330.too是将要进行seo的网址
# 初始化变量
url="https://www.0330.top/seo/api.php?url=www.0330.top"
page=1
total_success=0
# 循环,直到没有更多的页面需要处理
while true; do
# 调用API并获取结果
response=$(curl -s "$url?page=$page")
# 解析返回的JSON以获取成功数和下一页的URL
# 请根据实际返回的JSON字段调整下面的解析命令
current_success=$(echo $response | grep -o '"currentSuccessCount": *[0-9]*' | cut -d ':' -f 2 | tr -d ',"')
next_page_url=$(echo $response | grep '"nextPageUrl":' | cut -d '"' -f 4)
# 如果current_success为空,说明解析失败,可能是JSON格式不匹配或API返回了错误
if [ -z "$current_success" ]; then
echo "Error: Failed to parse current success count from response."
break
fi
# 累加成功数
total_success=$((total_success + current_success))
# 输出当前页的结果
echo "Page $page: Current Success Count = $current_success, Total Success Count = $total_success"
# 检查是否还有下一页
if [ -z "$next_page_url" ]; then
echo "All pages processed."
break
fi
# 更新页码
page=$((page + 1))
done
# 输出最终的总成功数
echo "Total Success Count after all pages: $total_success"
讲在宝塔面板的计划任务里添加shell脚本,将脚本里面的api改成你自己的
[...]超级外链工具,是一款在线全自动化发外链的推广工具。使用本工具可免费为网站在线批量增加外链,大大提高外链发布工作效率,是广大草根站长们必备的站长工具。api教程:https://www.0330.top/archives/55.html当我从网上看到SEO超级外链工具源码,试了试发现等他完成更新要很长时间,而且每天都要提交所以我写了SEO超级外链工具的api,通过宝塔的计划任务实现每天自动提交,我已[...]