npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@masx200/fetch-baidu-pan-files-api

v3.0.5

Published

模拟浏览器脚本操作,使用 nodejs 来批量读取和操作网盘文件信息, 获取目录的文件信息,模拟浏览器的脚本操作来发送网络请求

Readme

fetch-baidu-pan-files-api

功能说明

这个代码库是百度网盘批量清理重复文件计划的一部分。

模拟浏览器脚本操作,使用 nodejs 来批量读取和操作网盘文件信息

获取目录的文件信息,模拟浏览器的脚本操作来发送网络请求

还提供了直接获取指定目录下的所有文件信息的功能,若遇到网络错误自动重试

还提供了直接删除指定的批量文件的功能,多次尝试,判断要删除的文件是否存在

网盘对于每次删除操作的文件数有限制,故只能拆分多次尝试删除,轮询任务完成状态

百度网盘批量清理重复文件计划

https://github.com/masx200/baidu-pan-delete-repeated-files

https://github.com/masx200/fetch-baidu-pan-files-api

https://github.com/masx200/fetch-file-list-to-mongodb

https://github.com/masx200/mongodb-file-find-md5-repeat

使用方法

安装模块


yarn global add @masx200/fetch-baidu-pan-files-api

安装 node_modules

yarn install

编译脚本

yarn build

运行脚本

yarn start

使用前先获取 cookie

使用浏览器登陆百度网盘的网页版,并登陆

https://pan.baidu.com/

然后按F12打开浏览器的devtools

点击network页,选择监视Doc类型

然后刷新页面,点击下方的

https://pan.baidu.com/api/list

一行,右键选择copy,copy request headers,获得其中的cookie

获得如下内容


Cookie: BAIDUID=xxx; pan_login_way=xxx; PANWEB=xxx; BIDUPSID=xxx; PSTM=xxx; cflag=xxx; BDCLND=xxx; BDUSS=xxx; STOKEN=xxx; SCRC=xxx; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=xxx; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=xxx; PANPSC=xxx

提取出其中Cookie:后的内容为 cookie

./sshot-2020-02-26-[13-50-52].png

使用前先保存 cookie,并解析 cookie

保存 cookie 的方法

fetch-baidu-pan-files-api "--cookie=BAIDUID=xxx; pan_login_way=xxx; PANWEB=xxx; BIDUPSID=xxx; PSTM=xxx; cflag=xxx; BDCLND=xxx; BDUSS=xxx; STOKEN=xxx; SCRC=xxx; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=xxx; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=xxx; PANPSC=xxx"

详细的网盘 API

https://github.com/masx200/fetch-baidu-pan-files-api/tree/master/api

直接获取指定目录下的所有文件信息,若遇到网络错误自动重试

import { listonedir } from "@masx200/fetch-baidu-pan-files-api";
listonedir("/path/to/your/dir").then(console.log);

直接获取指定目录下的一页文件信息,若遇到网络错误自动重试,默认每页最多 1000 条

import { listdirpage } from "@masx200/fetch-baidu-pan-files-api";
listdirpage("/path/to/your/dir", 1).then(console.log);

先判断要删除的文件是否存在,然后直接删除指定的批量文件,若遇到网络错误多次尝试,

import { deletefiles } from "@masx200/fetch-baidu-pan-files-api";
deletefiles(["/path/to/your/file1", "/path/to/your/file2"]).then(console.log);

直接删除指定的批量文件,并获得任务的序号,若遇到网络错误多次尝试,

import { fetchdeletetaskid } from "@masx200/fetch-baidu-pan-files-api";
fetchdeletetaskid(["/path/to/your/file1", "/path/to/your/file2"]).then(
    console.log
);

查询一次任务的进度,根据任务的序号,若遇到网络错误多次尝试,

import { taskquerydeleteonce } from "@masx200/fetch-baidu-pan-files-api";
taskquerydeleteonce(278400522319194).then(console.log);

轮询查询任务的进度,根据任务的序号,直到任务成功为止,若遇到网络错误多次尝试,

import { taskquerydeletepoll } from "@masx200/fetch-baidu-pan-files-api";
taskquerydeletepoll(278400522319194).then(console.log);

changelog

2022 年 3 月 25 日 21:14:33

百度网盘 api 更新到 v2 了,没有 bdstoken 了,换成 csrf,并放入了 cookie 当中.