diff --git a/config.json b/config.json index a569af6..d425802 100644 --- a/config.json +++ b/config.json @@ -9,7 +9,7 @@ { "id": "task-1710000000001", "city": "南京市", - "prompt": "使用scrapling技能的fetch来爬取https://njggzy.nanjing.gov.cn/njweb/gchw/goods.html里房建市政、工程货物、交通水务、政府采购、产权交易、土地矿产、铁路航运和农村产权8个板块的招标公告列表的当天的的招标公告,获取项目名称 和项目金额(可能为合同预估价/最高投标限价等等),如果当天没有公告,默认获取最新的1条数据,不要试图写代码去正则匹配金额,因为金额的表述很多样,优先获取到详情md文件(或者html)后,使用`takeMoney`工具进行获取提取金额。\n输出结果为json,json结构如下\n```\n{\n \"results\": [\n\n {\n \"type\": \"比如房建市政\",\n\t\t\"project_name\": \"\",\n\t\t\"amount_yuan\": 0,\n\t\t\"date\": \"yyyy-MM-dd\",\n\t\t\"target_link: \"http...\"\n\t }\n ]\n}\n```", + "prompt": "使用scrapling技能的fetch来爬取https://njggzy.nanjing.gov.cn/njweb/gchw/goods.html里房建市政、工程货物、交通水务、政府采购、产权交易、土地矿产、铁路航运和农村产权8个板块的招标公告列表的当天的的招标公告,获取项目名称 和项目金额(可能为合同预估价/最高投标限价等等),如果当天没有公告,默认获取最新的1条数据,不要试图写代码去正则匹配金额,因为金额的表述很多样,优先获取到详情md文件(或者html)后,使用`takeMoney`工具进行获取提取金额。\n输出结果为json,json结构如下\n```\n{\n \"results\": [\n\n {\n \"type\": \"比如房建市政\",\n\t\t\"project_name\": \"\",\n\t\t\"amount_yuan\": 0,\n\t\t\"date\": \"yyyy-MM-dd\",\n\t\t\"detail_link: \"http...\"\n\t }\n ]\n}\n```", "enabled": true, "mode": "glm-5", "useBrowser": false diff --git a/public/index.html b/public/index.html index 4a65a2c..7ebb885 100644 --- a/public/index.html +++ b/public/index.html @@ -850,7 +850,7 @@ ${item.project_name || '-'} ${item.amount_yuan ? item.amount_yuan.toLocaleString() + ' 元' : '-'} ${item.date || '-'} - ${item.target_link ? `查看` : ''} + ${(item.detail_link || item.target_link) ? `查看` : ''} `).join('') : '
无数据
'; diff --git a/src/agentService.js b/src/agentService.js index c939775..c758d9e 100644 --- a/src/agentService.js +++ b/src/agentService.js @@ -100,7 +100,7 @@ async function checkTask(taskId, options = {}) { /** * 运行 agent 任务:创建 + 轮询直到完成 - * 返回 { results: [{ type, project_name, amount_yuan, date, target_link }] } + * 返回 { results: [{ type, project_name, amount_yuan, date, detail_link }] } */ export async function runAgentTask(prompt, options = {}) { const baseUrl = options.baseUrl || DEFAULT_BASE_URL; @@ -135,7 +135,13 @@ export async function runAgentTask(prompt, options = {}) { if (result.success) { console.log(`${logPrefix} 任务完成: ${result.message}`); const data = result.data || {}; - const results = Array.isArray(data.results) ? data.results : []; + const rawResults = Array.isArray(data.results) ? data.results : []; + const results = rawResults.map(item => { + if (!item || typeof item !== 'object') return item; + const detailLink = item.detail_link || item.target_link; + const { target_link, ...rest } = item; + return detailLink ? { ...rest, detail_link: detailLink } : rest; + }); console.log(`${logPrefix} 获取到 ${results.length} 条结果`); return { results }; } else { diff --git a/src/emailService.js b/src/emailService.js index 8967cf7..e126b42 100644 --- a/src/emailService.js +++ b/src/emailService.js @@ -785,7 +785,7 @@ function generateScraperResultsHtml(results) { date: item.date || '-', amount: amountText, hasAmount, - url: item.target_link || item.url || '', + url: item.detail_link || item.target_link || item.url || '', }); } }