导出选项

// response data:
// {
// "data": {
// "total": "4730",
// "pages": "473",
// "items": [
// {
// "id": "1388300880995165806",
// "name": "Jake"
// },
// {
// "id": "1388300880995165807",
// "name": "Mike"
// },
// {
// "id": "1388300880995165808",
// "name": "Fake"
// }
// ]
// }
// }

const url = `curl 'https://www.data.com/paged' \
-H 'accept: application/json' \
-H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8' \
-H 'authorization: Bearer token_value' \
-H 'content-type: application/json' \
-H 'origin: https://www.data.com' \
-H 'priority: u=1, i' \
-H 'referer: https://www.data.com/' \
-H 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Microsoft Edge";v="126"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Windows"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: same-site' \
-H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0' \
--data-raw '{"page":1,"size":10,"qyear":"2023","qId":"850257354107651400","qType":"ENTER","q":"l3"}'`
const command = parseCurl(url);
const req = {
command: command,
pageIndex: "page",
pageSize: "size",
pageTotal: "data.total",
listItem: "data.items",
pageRange: "2-5"
};
const list = await dataExport(req, (total, index) => { });

// if option in query url, use '_urlParams.' as root node. eg: https://www.data.com/page?page=1&size=10
// pageIndex = "_urlParams.page",
// pageSize = "_urlParams.size",
interface DataExportOption {
    command: HttpCommand;
    listItem: string;
    pageCount?: string;
    pageIndex: string;
    pageRange?: string;
    pageSize?: string;
    pageTotal?: string;
}

Properties

command: HttpCommand

请求命令 (可通过复制curl命令,调用 parseCurl 方法获取)

const command = parseCurl(curlString)
listItem: string

结果列表对象

pageCount?: string

分页总数

pageIndex: string

页码

pageRange?: string

页面范围(为空是全部页面;1,2,3 或者 2-5)

pageSize?: string

每页记录数

pageTotal?: string

记录总数