调整金额
This commit is contained in:
@@ -6,6 +6,7 @@ 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.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import us.codecraft.webmagic.Spider;
|
||||
@@ -23,6 +24,8 @@ public class CrawlerSchedule {
|
||||
private LoginInfoRepository loginInfoRepository;
|
||||
private static final int MAX_CRA = 3;
|
||||
private static final Integer ONOFF = 0;
|
||||
@Value("${pypath}")
|
||||
private String pypath;
|
||||
// 每天凌晨2点执行爬取开奖结果
|
||||
//@Scheduled(cron = "0 0 2 * * ?")
|
||||
// 每7秒执行一次爬取开奖结果
|
||||
@@ -55,7 +58,7 @@ public class CrawlerSchedule {
|
||||
System.out.println("使用token: " + (token.length() > 20 ? token.substring(0, 20) + "..." : token));
|
||||
|
||||
// 创建爬虫实例,传入token
|
||||
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token);
|
||||
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token,pypath);
|
||||
|
||||
String todayDate = DateUtils.getTodayDate();// 4. 执行爬虫
|
||||
String url = firstByOrderByCreateTimeDesc.getLoginUrl()+"/member/dresult?lottery=SGFT&date="+todayDate;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.tem.bocai.schedules;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.json.JSONArray;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -27,6 +28,9 @@ public class ExBetScriptSchedule {
|
||||
|
||||
@Autowired
|
||||
private BetRecordRepository betRecordRepository;
|
||||
|
||||
@Value("${pypath}")
|
||||
private String pypath;
|
||||
|
||||
/**
|
||||
* 处理文件路径,确保路径正确
|
||||
@@ -107,7 +111,7 @@ public class ExBetScriptSchedule {
|
||||
// 创建ProcessBuilder并设置工作目录为PyModel
|
||||
ProcessBuilder pb = new ProcessBuilder(command);
|
||||
// 设置工作目录为PyModel
|
||||
pb.directory(new java.io.File("PyModel"));
|
||||
pb.directory(new java.io.File(pypath));
|
||||
|
||||
// 执行Python脚本
|
||||
Process process = pb.start();
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.tem.bocai.util.*;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.val;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import net.sourceforge.tess4j.Tesseract;
|
||||
import org.apache.http.client.methods.*;
|
||||
@@ -32,6 +33,9 @@ public class LoginServiceImpl implements LoginService {
|
||||
private LoginInfoRepository loginInfoRepository;
|
||||
private static final int MAX_CRA = 3;
|
||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@Value("${pypath}")
|
||||
private String pypath;
|
||||
|
||||
|
||||
@Override
|
||||
public String loginAutomatic(LoginInfoParam loginInfoParam) {
|
||||
@@ -45,7 +49,7 @@ public class LoginServiceImpl implements LoginService {
|
||||
//保存用户信息
|
||||
addLoginInfo(loginInfoParam);
|
||||
// 2. 创建爬虫实例,传入token
|
||||
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token);
|
||||
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token,pypath);
|
||||
|
||||
// 3. 创建数据处理器
|
||||
LotteryDataPipeline pipeline = new LotteryDataPipeline();
|
||||
|
||||
@@ -34,8 +34,11 @@ public class LotteryWebMagicCrawler implements PageProcessor {
|
||||
// 添加一个字段标记是否成功解析数据
|
||||
private static volatile boolean lastParseSuccess = true;
|
||||
|
||||
public LotteryWebMagicCrawler(String token) {
|
||||
private String path;
|
||||
|
||||
public LotteryWebMagicCrawler(String token,String path) {
|
||||
this.token = token;
|
||||
this.path =path;
|
||||
initSite();
|
||||
}
|
||||
|
||||
@@ -289,7 +292,7 @@ public class LotteryWebMagicCrawler implements PageProcessor {
|
||||
String url = "https://4701268539-esh.qdk63ayw8g.com/member/dresult?lottery=SGFT&date=2026-01-18";
|
||||
|
||||
// 创建爬虫
|
||||
Spider.create(new LotteryWebMagicCrawler(""))
|
||||
Spider.create(new LotteryWebMagicCrawler("",""))
|
||||
.addUrl(url) // 添加起始URL
|
||||
.thread(1) // 线程数
|
||||
.run(); // 开始爬取
|
||||
|
||||
@@ -8,4 +8,6 @@ spring.datasource.password=
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect
|
||||
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
||||
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
||||
|
||||
pypath:d:/py/PyModel
|
||||
Reference in New Issue
Block a user