# scrapbox-python [](https://circleci.com/gh/HelloRusk/scrapbox-python) [](https://badge.fury.io/py/scrapbox) An unofficial wrapper around the [Scrapbox API](https://scrapbox.io/help-jp/API). ## Installation ```sh pip install scrapbox # or `pipenv install scrapbox` ``` ## Basic Use ```python import scrapbox client = scrapbox.Client() project = client.get("/pages/help-jp/") ``` ## Examples ### Get all the data of a project in JSON format ```python 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 ```python 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 ```python 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 ```python 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" ```