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 🙏

© 2024 – Pkg Stats / Ryan Hefner

qiita_export_all

v1.6.1

Published

export all of your article at qiita

Downloads

311

Readme

qiita_export_all

Node CI CircleCI Known Vulnerabilities FOSSA Status

NPM

Qiita v2 API を使って自身の投稿記事全てをエクスポートするツール。

Motivation

stakiran/qiita_exporterが類似ツールとしてすでにある。しかし

  • Python 2 である
  • 画像のダウンロードをやってくれない
  • 投稿数が 100 を超えて取得できない
  • HTML データやコメントなどの Markdown 以外のデータを保存してくれない
  • Python わからない

という不満があった。自分がよくわかってるのは C++か JavaScript だ。しかし C++で HTTPS 通信とか地獄すぎる。JavaScript しかないやろ。しかもasync/awaitがある。これはいい。

Requirement

  • Node.js 12.x 以降
  • npm

Installation

Node.js & npm

nvm もしくは nodist を使って Node.js と npm をインストールすることを推奨します。

nvm

nvm install 12.x
nvm use 12.x

nodist

nodist + 12.x
nodist 12.x
nodist npm match

Qiita API Access Token

Qiita API Access Token を手に入れます。

  1. Qiita にログインする
  2. 設定画面から個人用アクセストークンを発行する

説明のため、得た token が9226168a5ef65f8e81153b460e7c78f8b8e53394とします。各自読み替えてください。

cmd.exe

set QIITA_ACCESS_TOKEN=9226168a5ef65f8e81153b460e7c78f8b8e53394

sh

export QIITA_ACCESS_TOKEN=9226168a5ef65f8e81153b460e7c78f8b8e53394

Use

npx qiita_export_all

Docker

Node.js 環境がない場合でも Docker が利用可能な場合は、Docker で Qiita 記事のバックアップができます。

$ # リポジトリのクローンと移動
$ git clone https://github.com/yumetodo/qiita_export_all.git
$ cd qiita_export_all
$ # コンテナの作成
$ docker build -t qiita_export_all:local .
$ # コンテナの起動とアプリの実行。./export に出力されます(token は要置き換え)
$ docker run \
    --rm \
    --env QIITA_ACCESS_TOKEN=9226168a5ef65f8e81153b460e7c78f8b8e53394 \
    -v $(pwd)/export:/home/node/export \
    qiita_export_all:local
...
$ # 出力されたファイルの確認
$ tree ./export
...
  • 確認済み Docker version v19.03.5 (Intel, x86_64, AMD64)

Command Line options

Usage: qiita_export_all [options]

Options:
  -V, --version        output the version number
  -u, --user-id <id>   Qiita user id you want to download(default: the user who get QIITA_ACCESS_TOKEN).
  -o, --output <path>  Write output to <path> instead of current directory.
  --no-debug           disable print api limit per request
  -h, --help           output usage information

Note

  • md ファイルは UTF-8 でエクスポートします
  • 投稿数が 100 を超えていても取得できます
  • Windows ではMAX_PATHを超えるとエラーになる気がします
  • カレントディレクトリに Read/Write の権限がないとエラーになります
  • directory 名の一部に Qiita 記事のタイトルを使用しますが、パスとして無効な文字は削除されます。これはsanitize-filenameに丸投げしています。

Output

カレントディレクトリに出力します。生成される directory tree は

.
├── img
│   ├── 0_7.png
│   ├── 1_7.png
┊   ┊
├── items
│   ├── [ネタ]私のTLのみんながpure HTMLが何かを理解してくれない件
│   │   ├── comments
│   │   │   ├── 2017-02-02T145121+0900
│   │   │   │   ├── index.html
│   │   │   │   ├── info.json
│   │   │   │   └── README.md
│   │   │   ├── 2017-02-02T153542+0900
│   │   │   │   ├── index.html
│   │   │   │   ├── info.json
│   │   │   │   └── README.md
│   │   │   ├── 2017-02-02T160946+0900
│   │   │   │   ├── index.html
│   │   │   │   ├── info.json
│   │   │   │   └── README.md
│   │   │   ├── 2017-02-02T173054+0900
│   │   │   │   ├── index.html
│   │   │   │   ├── info.json
│   │   │   │   └── README.md
│   │   │   └── 2017-02-02T181039+0900
│   │   │       ├── index.html
│   │   │       ├── info.json
│   │   │       └── README.md
│   │   ├── index.html
│   │   ├── info.json
│   │   └── README.md
┊   ┊

のようなものです。

Development

Download

git なり zip で DL してあげればよいです。

git clone https://github.com/yumetodo/qiita_export_all.git
cd qiita_export_all
npm ci

Use

npm start

でとりあえずの実行はできます。

Example

$ npm start

> [email protected] start /home/yumetodo/qiita_export_all
> node bin/index.js

info: Requesting items...
request limit remain: 995/1000
request limit remain: 994/1000
info: 110 items found.
info: creating image save directory...
info: created.
info: Requesting comments/images...
request limit remain: 993/1000
request limit remain: 992/1000
request limit remain: 991/1000
request limit remain: 990/1000
request limit remain: 989/1000
request limit remain: 988/1000
request limit remain: 987/1000
When fetch https://scan.coverity.com/projects/1316/badge.svg (5886b2c0c421c24c909b/item), FetchError: request to https://scan.coverity.com/projects/1316/badge.svg failed, reason: Parse Error: Invalid header value char
request limit remain: 986/1000
request limit remain: 985/1000
request limit remain: 984/1000
request limit remain: 983/1000
request limit remain: 982/1000
request limit remain: 981/1000
request limit remain: 980/1000
request limit remain: 979/1000
request limit remain: 978/1000
request limit remain: 977/1000
request limit remain: 976/1000
request limit remain: 975/1000
request limit remain: 974/1000
request limit remain: 973/1000
request limit remain: 972/1000
request limit remain: 971/1000
request limit remain: 970/1000
request limit remain: 969/1000
request limit remain: 968/1000
request limit remain: 967/1000
request limit remain: 966/1000
request limit remain: 965/1000
When fetch https://pbs.twimg.com/media/C3kcEbkUcAAsbkn.jpg (34adcaeddaab8b58ab47/item), Error: Request failed with status code 404
request limit remain: 964/1000
request limit remain: 963/1000
request limit remain: 962/1000
request limit remain: 961/1000
request limit remain: 960/1000
request limit remain: 959/1000
request limit remain: 958/1000
request limit remain: 957/1000
request limit remain: 956/1000
request limit remain: 955/1000
request limit remain: 954/1000
request limit remain: 953/1000
request limit remain: 952/1000
request limit remain: 951/1000
request limit remain: 950/1000
request limit remain: 949/1000
request limit remain: 948/1000
request limit remain: 947/1000
request limit remain: 946/1000
request limit remain: 945/1000
request limit remain: 944/1000
request limit remain: 943/1000
request limit remain: 942/1000
request limit remain: 941/1000
request limit remain: 940/1000
request limit remain: 939/1000
request limit remain: 938/1000
request limit remain: 937/1000
request limit remain: 936/1000
request limit remain: 935/1000
info: Request finidhed.
info: Replacing Image path...
info: Replace finished.
info: Writing items/comments...
write finished.

License

Watch LICENSE.

FOSSA Status

Special thanks