暂无数据

This commit is contained in:
xuelijun
2026-01-23 10:03:05 +08:00
parent df2daa5a09
commit 2d055700d8
2 changed files with 11 additions and 4 deletions

View File

@@ -3,6 +3,8 @@ package com.tem.bocai.schedules;
import com.tem.bocai.entity.LoginInfoResult; import com.tem.bocai.entity.LoginInfoResult;
import com.tem.bocai.repository.LoginInfoRepository; import com.tem.bocai.repository.LoginInfoRepository;
import com.tem.bocai.util.*; import com.tem.bocai.util.*;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -20,14 +22,20 @@ public class CrawlerSchedule {
@Autowired @Autowired
private LoginInfoRepository loginInfoRepository; private LoginInfoRepository loginInfoRepository;
private static final int MAX_CRA = 3; private static final int MAX_CRA = 3;
private static final Integer ONOFF = 0;
// 每天凌晨2点执行爬取开奖结果 // 每天凌晨2点执行爬取开奖结果
//@Scheduled(cron = "0 0 2 * * ?") //@Scheduled(cron = "0 0 2 * * ?")
// 每7秒执行一次爬取开奖结果 // 每7秒执行一次爬取开奖结果
@Scheduled(cron = "*/9 * * * * ?") //@Scheduled(cron = "*/9 * * * * ?")
public void executeLotteryDraw() { public void executeLotteryDraw() {
System.out.println("开始爬取开奖结果..."); System.out.println("开始爬取开奖结果...");
int retryCount = 0; int retryCount = 0;
boolean success = false; boolean success = false;
LoginInfoResult firstByOrderByCreateTimeDesc = loginInfoRepository.findFirstByOrderByCreateTimeDesc()
.orElse(null);
if (firstByOrderByCreateTimeDesc == null) {
return;
}
String token = tokenCacheService.getToken(); String token = tokenCacheService.getToken();
while (!success && retryCount < MAX_CRA) { while (!success && retryCount < MAX_CRA) {
@@ -44,8 +52,7 @@ public class CrawlerSchedule {
// 创建爬虫实例传入token // 创建爬虫实例传入token
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token); LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token);
LoginInfoResult firstByOrderByCreateTimeDesc = loginInfoRepository.findFirstByOrderByCreateTimeDesc()
.orElse(null);
String YesterdayDate = DateUtils.getYesterdayDate();// 4. 执行爬虫 String YesterdayDate = DateUtils.getYesterdayDate();// 4. 执行爬虫
String url = firstByOrderByCreateTimeDesc.getLoginUrl()+"/member/dresult?lottery=SGFT&date="+YesterdayDate; String url = firstByOrderByCreateTimeDesc.getLoginUrl()+"/member/dresult?lottery=SGFT&date="+YesterdayDate;

View File

@@ -75,7 +75,7 @@ public class CompletedTodayCrawler implements PageProcessor {
// 检查是否有"暂无数据"提示 // 检查是否有"暂无数据"提示
if (content.contains("暂无数据")) { if (content.contains("暂无数据")) {
System.out.println("警告: 页面显示'暂无数据'"); System.out.println("警告: 页面显示'暂无数据'");
lastParseSuccess = false; // 标记失败 lastParseSuccess = true; // 标记失败
return; return;
} }
// 解析注单数据 // 解析注单数据