Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get接口,浏览器能直接访问调用,但工具不行,疑似URL编码问题 #113

Closed
guicaiyue opened this issue May 13, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@guicaiyue
Copy link

Bug 预期

预期:浏览器可直接调用成功
实际:接口调用失败,因为无法识别url

最小可重复的例子

import { createCrawl } from 'x-crawl'

const crawlApp = createCrawl({ intervalTime: { max: 3000, min: 1000 } })
let aar =["https://suno-list.com/api/suno/validateLink?link=https%3A%2F%2Fsuno.com%2Fsong%2Fe8b369f2-e2fc-4152-b2aa-d29224d43041"]
    crawlApp.crawlData({ aar }).then((twoRes) => {
        // 处理接口链接
        console.log(twoRes);
        for(let one of twoRes){
            // 这里报错
        }
        console.log(downloadLinks);
    });

报错信息

TypeError: Invalid URL

x-crawl 版本

x-crawl 10.0.1

Node 版本

v20.12.1

包管理器

pnpm

包管理器版本

8.3.1

@guicaiyue guicaiyue added the bug Something isn't working label May 13, 2024
Copy link

Welcome to submit an issue for x-crawl for the first time

@coder-hxl
Copy link
Owner

coder-hxl commented May 13, 2024

你好,你这个用法是错误的,这样会导致 x-crawl 无法正确获取 URL ,看示例应该用的是 混合目标数组配置 或者 进阶配置

正确的配置

crawlApp.crawlData(aar)
// 或者
crawlApp.crawlData({ targets: aar })

错误的配置

crawlApp.crawlData({ aar })

x-crawl 没有 aar 选项

@coder-hxl
Copy link
Owner

建议搭配 TypeScript 使用

@guicaiyue
Copy link
Author

你好,你这个用法是错误的,这样会导致 x-crawl 无法正确获取 URL ,看示例应该用的是 混合目标数组配置 或者 进阶配置

正确的配置

crawlApp.crawlData(aar)
// 或者
crawlApp.crawlData({ targets: aar })

错误的配置

crawlApp.crawlData({ aar })

x-crawl 没有 aar 选项

懂了,我知道问题的原因了

@guicaiyue
Copy link
Author

建议搭配 TypeScript 使用

请问我如何实现zip文件的解压,因为工具是ECMAScript 模块,试了adm-zip,没法使用,因为它是CommonJS 模块

@coder-hxl
Copy link
Owner

@guicaiyue ESM 可以导入 CJS,现在 Node.js 22 版本的 CJS 也能导入 ESM 了

@guicaiyue
Copy link
Author

@guicaiyue ESM 可以导入 CJS,现在 Node.js 22 版本的 CJS 也能导入 ESM 了

还是没做到,我现在是在青龙面板里面常用使用这个脚本,每个脚本都是单个ts文件,所以无法同时支持ECMAScript 与CommonJS 模块吧,但 fs 也是能用,nodejs的CJS 和 ESM 割裂性也太强烈了

import { createCrawl } from 'x-crawl';
import fs from 'fs';
import AdmZip from 'adm-zip';

@coder-hxl
Copy link
Owner

@guicaiyue 有什么报错信息不

@guicaiyue
Copy link
Author

找不到模块的异常,人麻了
image

@coder-hxl
Copy link
Owner

coder-hxl commented May 14, 2024

@guicaiyue 把 node_modules 删了重新下载试试,或者试试其他的解压库

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants