1
This commit is contained in:
@@ -3,8 +3,6 @@ import type { PlatformFieldConfig } from '@/types';
|
||||
/** DOM 抓取后的通用结果结构。 */
|
||||
export type DomScrapeResult = Record<string, unknown>;
|
||||
|
||||
/** 默认等待时间,用于点击后或翻页后等待页面渲染。 */
|
||||
const DEFAULT_DELAY = 1500;
|
||||
|
||||
/**
|
||||
* 在目标网页上下文中执行 DOM 抓取。
|
||||
@@ -22,7 +20,7 @@ export async function scrapeDomFields(fields: PlatformFieldConfig[]): Promise<Do
|
||||
|
||||
|
||||
/** 睡眠工具,给点击、翻页、异步渲染留出等待时间。 */
|
||||
const sleep = (ms?: number) => new Promise((resolve) => window.setTimeout(resolve, ms ?? DEFAULT_DELAY));
|
||||
const sleep = (ms?: number) => new Promise((resolve) => window.setTimeout(resolve, ms ?? 1500));
|
||||
|
||||
/** 从元素中提取实际值,默认取文本,也支持 attr、图片 src、链接 href。 */
|
||||
function extractValue(el: Element | null, config: PlatformFieldConfig): string | null {
|
||||
|
||||
Reference in New Issue
Block a user