爬虫实现,修改class转样式,前端渲染
This commit is contained in:
@@ -58,7 +58,7 @@ public class TaskExecutor {
|
||||
log.setDeleted(false);
|
||||
|
||||
try {
|
||||
log.setExecuteStatus(0);
|
||||
log.setExecuteStatus(2);
|
||||
log.setExecuteMessage("执行中");
|
||||
int i = logMapper.insertLog(log);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.xyzh.api.system.role.RoleService;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.crontab.TbCrontabEmailDefault;
|
||||
import org.xyzh.common.dto.crontab.TbCrontabEmailRecipient;
|
||||
import org.xyzh.common.dto.crontab.TbCrontabLog;
|
||||
import org.xyzh.common.dto.crontab.TbCrontabTask;
|
||||
import org.xyzh.common.dto.crontab.TbCrontabTaskMeta;
|
||||
import org.xyzh.common.dto.crontab.TbDataCollectionItem;
|
||||
@@ -25,6 +26,7 @@ import org.xyzh.common.utils.NonUtils;
|
||||
import org.xyzh.common.vo.DataCollectionItemVO;
|
||||
import org.xyzh.common.vo.ResourceVO;
|
||||
import org.xyzh.common.vo.UserDeptRoleVO;
|
||||
import org.xyzh.crontab.mapper.CrontabLogMapper;
|
||||
import org.xyzh.crontab.pojo.TaskParams;
|
||||
import org.xyzh.crontab.task.PythonCommandTask;
|
||||
|
||||
@@ -79,6 +81,8 @@ public class NewsCrawlerTask extends PythonCommandTask {
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private CrontabLogMapper logMapper;
|
||||
/**
|
||||
* 构建Python脚本参数
|
||||
*/
|
||||
@@ -132,9 +136,12 @@ public class NewsCrawlerTask extends PythonCommandTask {
|
||||
String pythonArg = "--"+key;
|
||||
if (pythonArg != null && value != null) {
|
||||
if (value instanceof Boolean) {
|
||||
// Boolean类型: true时只传参数名,false时不传
|
||||
if ((Boolean) value) {
|
||||
args.add(pythonArg);
|
||||
args.add("true");
|
||||
}else{
|
||||
args.add(pythonArg);
|
||||
args.add("false");
|
||||
}
|
||||
} else {
|
||||
// String/Integer类型: 传参数名+值
|
||||
@@ -305,6 +312,13 @@ public class NewsCrawlerTask extends PythonCommandTask {
|
||||
} else {
|
||||
logger.warn("没有有效的新闻数据需要保存");
|
||||
}
|
||||
if(passList.isEmpty() && notPassList.isEmpty()){
|
||||
TbCrontabLog log = new TbCrontabLog();
|
||||
log.setID(logId);
|
||||
log.setExecuteStatus(1);
|
||||
log.setExecuteMessage("未爬取到数据");
|
||||
int i = logMapper.updateLog(log);
|
||||
}
|
||||
|
||||
// 自动发布并记录成功发布的 URL 集合
|
||||
Set<String> publishedUrls = new HashSet<>();
|
||||
|
||||
Reference in New Issue
Block a user