Skip to main content

An unofficial wrapper around the Scrapbox API

Project description

scrapbox-python

CircleCI PyPI version

An unofficial wrapper around the Scrapbox API.

Installation

pip install scrapbox
# or `pipenv install scrapbox`

Basic Use

import scrapbox

client = scrapbox.Client()
project = client.get("/pages/help-jp/")

Examples

Get all the data of a project in JSON format

import json

client = scrapbox.Client()
project = client.get("/pages/help-jp/", limit=10)
# https://scrapbox.io/help-jp/

print(json.dumps(project, ensure_ascii=False, indent=2))
"""
{
  "projectName": "help-jp",
  "skip": 0,
  "limit": 10,
  "count": 73,
  "pages": [
    {
      "id": "57c7d72ad25ef00f00100688",
      "title": "Scrapboxの使い方",
      "image": "https://gyazo.com/7057219f5b20ca8afd122945b72453d3/raw",
      "descriptions": [
        "[https://gyazo.com/7057219f5b20ca8afd122945b72453d3]",
        "Scrapbox(スクラップボックス)の使い方・活用方法についてご紹介します。",
        "[* 編集を始める]",
        "まず最初に[ブラケティング]を読んでみましょう",
        "[* チュートリアルで雰囲気をつかむ]"
      ],
      "user": {
        "id": "566f8b954fb08e1100af5c5b"
      },
      "pin": 9007197717386014,
      "views": 34396,
      "linked": 2,
      "commitId": "5cf9c78742fc7800179f8c19",
      "created": 1472713402,
      "updated": 1559271981,
      "accessed": 1562487581,
      "snapshotCreated": 1559315996
    },
...
"""

Get page data in JSON format

import json

client = scrapbox.Client()
page = client.get("/pages/help-jp/API")
# https://scrapbox.io/help-jp/API

print(json.dumps(page, ensure_ascii=False, indent=2))
"""
{
  "id": "58e67688d0a4fe0011a0249c",
  "title": "API",
  "image": "https://gyazo.com/5bf55bb6223a62bf4477f07a9aad39b8/raw",
  "descriptions": [
    "[https://gyazo.com/5bf55bb6223a62bf4477f07a9aad39b8]",
    "あくまで内部APIです。APIは予告なく変更を行います。",
    "ページデータを取得するAPI",
    "ページリスト",
    "`/api/pages/:projectName`"
  ],
  "user": {
    "id": "5724627723541f110097c291",
    "name": "shokai",
    "displayName": "Sho Hashimoto",
    "photo": "https://lh3.googleusercontent.com/-auiW-ZOVu6Y/AAAAAAAAAAI/AAAAAAAADLg/YwBeR9cziLU/photo.jpg"
  },
  "pin": 0,
  "views": 7072,
  "linked": 1,
  "commitId": "5d135304ff5b5d0017cd83cc",
  "created": 1491498636,
  "updated": 1561547524,
  "accessed": 1562490240,
  "snapshotCreated": 1561586966,
  "persistent": true,
  "lines": [
    {
      "id": "58e67688d0a4fe0011a0249c",
      "text": "API",
      "userId": "5724627723541f110097c291",
      "created": 1491498636,
      "updated": 1491499158
    },
...
"""

Get the body text of a page

client = scrapbox.Client()
text = client.get("/pages/help-jp/Scrapboxの使い方/text")

print(text)
"""
Scrapboxの使い方
[https://gyazo.com/7057219f5b20ca8afd122945b72453d3]
Scrapbox(スクラップボックス)の使い方・活用方法についてご紹介します。

[* 編集を始める]
	まず最初に[ブラケティング]を読んでみましょう

[* チュートリアルで雰囲気をつかむ]
 サンプルプロジェクト
 	Scrapboxを開発するNotaが実際に利用したページを一部そのまま公開します。
   [Nota社のScrapboxを一部公開 https://scrapbox.io/nota-private-sample/]
	[Scrapboxチュートリアルスライド]
		使い方の概要を掴むことができます
 実践テクニック
  [エンジニアの生産性をあげるScrapboxの使い方 https://scrapbox.io/business/tutorial]
...
"""

Get the title image of a page

client = scrapbox.Client()

raw_image = client.get("/pages/help-jp/Scrapboxの使い方/icon")
with open("title.jpg", "wb") as f:
    f.write(raw_image)
# Download the top icon as "title.jpg"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scrapbox-0.6.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scrapbox-0.6.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file scrapbox-0.6.1.tar.gz.

File metadata

  • Download URL: scrapbox-0.6.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for scrapbox-0.6.1.tar.gz
Algorithm Hash digest
SHA256 2087e385de9f1ee8e63bd54a5e4e376ac0fc155fee91b4b579b53a700d67bd7c
MD5 02a9e74e8443b565baac3ccc81237792
BLAKE2b-256 84deeef28840102ee23cc1dee4246e2f9387919c2f542bd64152e86950c2990f

See more details on using hashes here.

File details

Details for the file scrapbox-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: scrapbox-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

File hashes

Hashes for scrapbox-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 78a21b6e1d46b4c0ecd87be591e12bbe9abb6aec7d996d06ec3aea8f2d00e666
MD5 61077844ea2c4617cbce5e26d22a72e5
BLAKE2b-256 41f7df46b4c127d1a389b33c016e1b51fa487ba10e8606287c985fa33dc33ceb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page