调整金额
This commit is contained in:
27
pom.xml
27
pom.xml
@@ -92,11 +92,38 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>bocai</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>net.roseboy</groupId>
|
||||||
|
<artifactId>classfinal-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>classFinal</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<!-- 加密密码(必填) -->
|
||||||
|
<password>#</password>
|
||||||
|
<!-- 需加密的包名(可选,多个用逗号分隔) -->
|
||||||
|
<packages>com.tem.bocai</packages>
|
||||||
|
<!-- 排除加密的类(可选) -->
|
||||||
|
<excludes>org.springframework.*</excludes>
|
||||||
|
<!-- 机器码(可选,绑定机器) -->
|
||||||
|
<!-- <code>xxxxxx</code>-->
|
||||||
|
<!-- 调试模式(可选) -->
|
||||||
|
<debug>false</debug>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
@@ -6,6 +6,7 @@ import com.tem.bocai.util.*;
|
|||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import us.codecraft.webmagic.Spider;
|
import us.codecraft.webmagic.Spider;
|
||||||
@@ -23,6 +24,8 @@ public class CrawlerSchedule {
|
|||||||
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;
|
private static final Integer ONOFF = 0;
|
||||||
|
@Value("${pypath}")
|
||||||
|
private String pypath;
|
||||||
// 每天凌晨2点执行爬取开奖结果
|
// 每天凌晨2点执行爬取开奖结果
|
||||||
//@Scheduled(cron = "0 0 2 * * ?")
|
//@Scheduled(cron = "0 0 2 * * ?")
|
||||||
// 每7秒执行一次爬取开奖结果
|
// 每7秒执行一次爬取开奖结果
|
||||||
@@ -55,7 +58,7 @@ public class CrawlerSchedule {
|
|||||||
System.out.println("使用token: " + (token.length() > 20 ? token.substring(0, 20) + "..." : token));
|
System.out.println("使用token: " + (token.length() > 20 ? token.substring(0, 20) + "..." : token));
|
||||||
|
|
||||||
// 创建爬虫实例,传入token
|
// 创建爬虫实例,传入token
|
||||||
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token);
|
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token,pypath);
|
||||||
|
|
||||||
String todayDate = DateUtils.getTodayDate();// 4. 执行爬虫
|
String todayDate = DateUtils.getTodayDate();// 4. 执行爬虫
|
||||||
String url = firstByOrderByCreateTimeDesc.getLoginUrl()+"/member/dresult?lottery=SGFT&date="+todayDate;
|
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.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -28,6 +29,9 @@ public class ExBetScriptSchedule {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BetRecordRepository betRecordRepository;
|
private BetRecordRepository betRecordRepository;
|
||||||
|
|
||||||
|
@Value("${pypath}")
|
||||||
|
private String pypath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理文件路径,确保路径正确
|
* 处理文件路径,确保路径正确
|
||||||
* @param filePath 文件路径
|
* @param filePath 文件路径
|
||||||
@@ -107,7 +111,7 @@ public class ExBetScriptSchedule {
|
|||||||
// 创建ProcessBuilder并设置工作目录为PyModel
|
// 创建ProcessBuilder并设置工作目录为PyModel
|
||||||
ProcessBuilder pb = new ProcessBuilder(command);
|
ProcessBuilder pb = new ProcessBuilder(command);
|
||||||
// 设置工作目录为PyModel
|
// 设置工作目录为PyModel
|
||||||
pb.directory(new java.io.File("PyModel"));
|
pb.directory(new java.io.File(pypath));
|
||||||
|
|
||||||
// 执行Python脚本
|
// 执行Python脚本
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.tem.bocai.util.*;
|
|||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import net.sourceforge.tess4j.Tesseract;
|
import net.sourceforge.tess4j.Tesseract;
|
||||||
import org.apache.http.client.methods.*;
|
import org.apache.http.client.methods.*;
|
||||||
@@ -32,6 +33,9 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
private LoginInfoRepository loginInfoRepository;
|
private LoginInfoRepository loginInfoRepository;
|
||||||
private static final int MAX_CRA = 3;
|
private static final int MAX_CRA = 3;
|
||||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
@Value("${pypath}")
|
||||||
|
private String pypath;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String loginAutomatic(LoginInfoParam loginInfoParam) {
|
public String loginAutomatic(LoginInfoParam loginInfoParam) {
|
||||||
@@ -45,7 +49,7 @@ public class LoginServiceImpl implements LoginService {
|
|||||||
//保存用户信息
|
//保存用户信息
|
||||||
addLoginInfo(loginInfoParam);
|
addLoginInfo(loginInfoParam);
|
||||||
// 2. 创建爬虫实例,传入token
|
// 2. 创建爬虫实例,传入token
|
||||||
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token);
|
LotteryWebMagicCrawler crawler = new LotteryWebMagicCrawler(token,pypath);
|
||||||
|
|
||||||
// 3. 创建数据处理器
|
// 3. 创建数据处理器
|
||||||
LotteryDataPipeline pipeline = new LotteryDataPipeline();
|
LotteryDataPipeline pipeline = new LotteryDataPipeline();
|
||||||
|
|||||||
@@ -34,8 +34,11 @@ public class LotteryWebMagicCrawler implements PageProcessor {
|
|||||||
// 添加一个字段标记是否成功解析数据
|
// 添加一个字段标记是否成功解析数据
|
||||||
private static volatile boolean lastParseSuccess = true;
|
private static volatile boolean lastParseSuccess = true;
|
||||||
|
|
||||||
public LotteryWebMagicCrawler(String token) {
|
private String path;
|
||||||
|
|
||||||
|
public LotteryWebMagicCrawler(String token,String path) {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
|
this.path =path;
|
||||||
initSite();
|
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";
|
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
|
.addUrl(url) // 添加起始URL
|
||||||
.thread(1) // 线程数
|
.thread(1) // 线程数
|
||||||
.run(); // 开始爬取
|
.run(); // 开始爬取
|
||||||
|
|||||||
@@ -9,3 +9,5 @@ spring.jpa.hibernate.ddl-auto=update
|
|||||||
spring.jpa.show-sql=true
|
spring.jpa.show-sql=true
|
||||||
spring.jpa.database-platform=org.hibernate.community.dialect.SQLiteDialect
|
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