csdnsynchexo
TypeScript icon, indicating that this package has built-in type declarations

3.2.3 • Public • Published

Welcome to csdnsynchexo 👋

Version Documentation Maintenance download License: MIT

支持 csdn/博客园/掘金/segmentfault/腾讯云加社区/github 等平台一键迁移 hexo

Usage

cli 使用

# help
npx csdnsynchexo@latest  --help
# 命令行
npx csdnsynchexo@latest --userId 289926799429704 --type juejin --output ./example
# or 指定配置文件
npx csdnsynchexo@latest --config ./config.json
{
  "userId": "289926799429704",
  "type": "juejin",
  "output": "./example"
}

example

api 使用

const { run } = require('csdnsynchexo')
const config = {
  userId: '289926799429704',
  type: 'juejin',
  output: './example',
}
run(config).then((res) => {
  console.log(res)
  //   {
  //   title: string
  //   date: string
  //   tags: string[]
  //   categories: string[]
  //   content: string
  // }[]
})

交互式输入 TODO

支持平台

csdn

  • type csdn

  • userId csdn 用户名。如https://blog.csdn.net/flytam的 flytam

  • output 输出路径。默认.

  • cookie

    • csdn cookie 信息,不提供则使用爬虫获取;提供则 api 获取
    • 获取方式:新开一个页面,F12(mac: cmd+shift+i)打开控制台,点击抓包这个请求的request headers中的cookie后面那段值

掘金

  • type juejin

  • userId 掘金用户 id。如https://juejin.cn/user/289926799429704/posts289926799429704

  • output 输出路径。默认.

  • cookie 掘金 cookie 信息。不提供使用非鉴权 api,部分老文章 markdown 格式可能有问题

博客园

  • type bokeyuan
  • userId 博客园用户 id。如https://www.cnblogs.com/flytam/flytam
  • output 输出路径。默认.

segmentfault

  • type segmentfault
  • userId segmentfault id。如https://segmentfault.com/u/flytamflytam
  • output 输出路径。默认.

腾讯云加社区

  • type tengxunyun
  • userId 腾讯云加社区 id。如https://cloud.tencent.com/developer/user/1132538/articles1132538
  • output 输出路径。默认.

github issue 博客

  • type github

  • userId githun 用户名,如https://github.com/flytam的 flytam

  • repo 写博客的仓库,如https://github.com/flytam/blog的 blog

    掘金小册

  • type juejin_book

  • userId 掘金小册id,如https://juejin.cn/book/7070324244772716556 的7070324244772716556

  • cookie 掘金已购买小册的账号cookie信息

高级选项 beta

图片自动转存

  • imgConfig 图片转存配置文件

部分网站有防盗链功能,支持配置自动转存,转存功能使用了PicGo。具体配置可参考 1 参考 2

例如:爬取掘金上的文章,图片转存上传到 github 上

1、新建一个 PiGo 配置文件,如(更多配置请参考 picgo)

// img.json
{
  "picBed": {
    "uploader": "github",
    "github": {
      "repo": "flytam/cdn",
      "token": "xxxxx",
      "path": "img/"
    }
  }
}

2、执行

npx csdnsynchexo@latest --config ./config.json
{
  "userId": "xxxx",
  "type": "juejin",
  "output": "./example",
  "imgConfig": "./img.json"
}

tips:网络原因呢转存 github 很容易超时。建议选择其它平台,参考 picgo

Run tests

# todo 简单测测
npm run test

Author

👤 flytam

  • Website: github.com/flytam/blog
  • Github: @flytam

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 flytam.
This project is MIT licensed.

Package Sidebar

Install

npm i csdnsynchexo

Weekly Downloads

3

Version

3.2.3

License

MIT

Unpacked Size

99.1 kB

Total Files

75

Last publish

Collaborators

  • flytam