暂无数据
This commit is contained in:
@@ -3,6 +3,8 @@ package com.tem.bocai.schedules;
|
||||
import com.tem.bocai.entity.LoginInfoResult;
|
||||
import com.tem.bocai.repository.LoginInfoRepository;
|
||||
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.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -20,14 +22,20 @@ public class CrawlerSchedule {
|
||||
@Autowired
|
||||
private LoginInfoRepository loginInfoRepository;
|
||||
private static final int MAX_CRA = 3;
|
||||
private static final Integer ONOFF = 0;
|
||||
// 每天凌晨2点执行爬取开奖结果
|
||||
//@Scheduled(cron = "0 0 2 * * ?")
|
||||
// 每7秒执行一次爬取开奖结果
|
||||
@Scheduled(cron = "*/9 * * * * ?")
|
||||
//@Scheduled(cron = "*/9 * * * * ?")
|
||||
public void executeLotteryDraw() {
|
||||
System.out.println("开始爬取开奖结果...");
|
||||
int retryCount = 0;
|
||||
boolean success = false;
|
||||
LoginInfoResult firstByOrderByCreateTimeDesc = loginInfoRepository.findFirstByOrderByCreateTimeDesc()
|
||||
.orElse(null);
|
||||
if (firstByOrderByCreateTimeDesc == null) {
|
||||
return;
|
||||
}
|
||||
String token = tokenCacheService.getToken();
|
||||
|
||||
while (!success && retryCount < MAX_CRA) {
|
||||
@@ -44,8 +52,7 @@ public class CrawlerSchedule {
|
||||
|
||||
// 创建爬虫实例,传入token
|
||||
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token);
|
||||
LoginInfoResult firstByOrderByCreateTimeDesc = loginInfoRepository.findFirstByOrderByCreateTimeDesc()
|
||||
.orElse(null);
|
||||
|
||||
String YesterdayDate = DateUtils.getYesterdayDate();// 4. 执行爬虫
|
||||
String url = firstByOrderByCreateTimeDesc.getLoginUrl()+"/member/dresult?lottery=SGFT&date="+YesterdayDate;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CompletedTodayCrawler implements PageProcessor {
|
||||
// 检查是否有"暂无数据"提示
|
||||
if (content.contains("暂无数据")) {
|
||||
System.out.println("警告: 页面显示'暂无数据'");
|
||||
lastParseSuccess = false; // 标记失败
|
||||
lastParseSuccess = true; // 标记失败
|
||||
return;
|
||||
}
|
||||
// 解析注单数据
|
||||
|
||||
Reference in New Issue
Block a user