Created
January 9, 2022 12:22
-
-
Save myazakky/35a566a3a96b8286940d892544a7ee85 to your computer and use it in GitHub Desktop.
scrapbox ->slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import json | |
class Page: | |
def __init__(self, data): | |
self.id = data["id"] | |
self.title = data["title"] | |
self.descriptions = data["descriptions"] | |
self.project = data["project"] | |
self.url = data["url"] | |
self.image_url = data["image"] | |
@classmethod | |
def get(self, token, project, title): | |
url = f'https://scrapbox.io/api/pages/{project}/{title}' | |
req = urllib.request.Request(url) | |
req.add_header("Cookie", f"connect.sid={token}") | |
with urllib.request.urlopen(req) as res: | |
body = res.read() | |
data = json.loads(body) | |
data["project"] = project | |
data["url"] = url | |
return Page(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment