Skip to content

Instantly share code, notes, and snippets.

@myazakky
Created January 9, 2022 12:22
Show Gist options
  • Save myazakky/35a566a3a96b8286940d892544a7ee85 to your computer and use it in GitHub Desktop.
Save myazakky/35a566a3a96b8286940d892544a7ee85 to your computer and use it in GitHub Desktop.
scrapbox ->slack
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