save
This commit is contained in:
parent
35944a46d7
commit
f8dc38e673
|
@ -13,6 +13,7 @@
|
|||
"dependencies": {
|
||||
"axios": "^1.7.9",
|
||||
"cheerio": "^1.0.0",
|
||||
"g": "^2.0.1",
|
||||
"puppeteer": "^24.2.1",
|
||||
"uuid": "^11.0.5"
|
||||
},
|
||||
|
|
|
@ -14,6 +14,9 @@ importers:
|
|||
cheerio:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
g:
|
||||
specifier: ^2.0.1
|
||||
version: 2.0.1
|
||||
puppeteer:
|
||||
specifier: ^24.2.1
|
||||
version: 24.2.1(typescript@5.7.3)
|
||||
|
@ -346,6 +349,9 @@ packages:
|
|||
function-bind@1.1.2:
|
||||
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
||||
|
||||
g@2.0.1:
|
||||
resolution: {integrity: sha512-Fi6Ng5fZ/ANLQ15H11hCe+09sgUoNvDEBevVgx3KoYOhsH5iLNPn54hx0jPZ+3oSWr+xajnp2Qau9VmPsc7hTA==}
|
||||
|
||||
get-caller-file@2.0.5:
|
||||
resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==}
|
||||
engines: {node: 6.* || 8.* || >= 10.*}
|
||||
|
@ -976,6 +982,8 @@ snapshots:
|
|||
|
||||
function-bind@1.1.2: {}
|
||||
|
||||
g@2.0.1: {}
|
||||
|
||||
get-caller-file@2.0.5: {}
|
||||
|
||||
get-intrinsic@1.2.7:
|
||||
|
|
|
@ -3,6 +3,7 @@ import { fetchData } from "./link";
|
|||
function main() {
|
||||
console.log("Hello, this is the main function!");
|
||||
fetchData("AI写作工具")
|
||||
// test()
|
||||
}
|
||||
|
||||
main();
|
||||
|
|
|
@ -28,7 +28,7 @@ export async function fetchData(typeName: string) {
|
|||
|
||||
// 提取工具卡片数据
|
||||
const toolsData = [] as any;
|
||||
$('.url-card').each(async (index: any, element: any) => {
|
||||
for (const element of $('.url-card')) {
|
||||
const name = $(element).find('.url-info strong').text().trim();
|
||||
const tempLink = $(element).find('a').attr('href') as string;
|
||||
const description = $(element).find('.url-info p').text().trim();
|
||||
|
@ -41,7 +41,7 @@ export async function fetchData(typeName: string) {
|
|||
}
|
||||
// 假设工具的类别是固定的,比如 "AI写作工具"
|
||||
const type = typeName;
|
||||
const priority = index + 1; // 根据索引来定义优先级
|
||||
const priority = 1; // 根据索引来定义优先级
|
||||
const addTime = Date.now();
|
||||
const logoLink = await downloadImage(_originLink)
|
||||
// console.log(logoLink);
|
||||
|
@ -58,8 +58,10 @@ export async function fetchData(typeName: string) {
|
|||
addTime,
|
||||
};
|
||||
|
||||
await toolsData.push(toolData);
|
||||
});
|
||||
toolsData.push(toolData);
|
||||
console.log('完成' );
|
||||
|
||||
}
|
||||
console.log(toolsData);
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
import { resolve } from "path"
|
||||
|
||||
function asyncFunction() {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
console.log('time out');
|
||||
|
||||
resolve(1)
|
||||
}, 1000)
|
||||
})
|
||||
}
|
||||
export default async function test() {
|
||||
const list = [1, 2, 3]
|
||||
const result: number[] = [];
|
||||
await (async () => {
|
||||
console.log('前');
|
||||
|
||||
list.forEach(async (val) => {
|
||||
result.push(val)
|
||||
console.log('-前');
|
||||
|
||||
await asyncFunction()
|
||||
result.push(val)
|
||||
console.log('-后');
|
||||
|
||||
|
||||
})
|
||||
console.log('后');
|
||||
|
||||
})()
|
||||
console.log(result);
|
||||
|
||||
}
|
Loading…
Reference in New Issue