Spaces:
Paused
Paused
Download test/parse_cgi_data.ts from asemxin1976/wechat-article: direct link, hf CLI and curl.
- Browser
- Download file 903 Bytes
-
https://huggingface.co/spaces/asemxin1976/wechat-article/resolve/main/test/parse_cgi_data.ts
- Command line
-
hf download hf://spaces/asemxin1976/wechat-article/test/parse_cgi_data.ts
-
curl -L -o parse_cgi_data.ts https://huggingface.co/spaces/asemxin1976/wechat-article/resolve/main/test/parse_cgi_data.ts
903 Bytes
| import { parseCgiDataNew } from '#shared/utils/html'; | |
| import { read, samples, write } from './common'; | |
| function normalizeOutPath(input: string): string { | |
| const segments = input.split('/'); | |
| segments[segments.length - 1] = 'output/parse-' + segments[segments.length - 1]; | |
| return segments.join('/').replace(/\.html$/, '.json'); | |
| } | |
| async function run() { | |
| for (const group of samples.filter(group => group.hasContent)) { | |
| console.group(group.name); | |
| for (const samplePath of group.samples) { | |
| const html = read(samplePath); | |
| const cgiData = await parseCgiDataNew(html); | |
| if (!cgiData) { | |
| console.warn('提取 window.cgiDataNew 对象失败'); | |
| continue; | |
| } | |
| console.log('item_show_type:', cgiData.item_show_type); | |
| write(normalizeOutPath(samplePath), JSON.stringify(cgiData, null, 2)); | |
| } | |
| console.groupEnd(); | |
| console.log(); | |
| } | |
| } | |
| run(); | |