Skip to content

Commit 9d9f567

Browse files
committed
api function to get dictionary of all ST members - webscraped from a .js file
1 parent 21a1245 commit 9d9f567

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

scratchattach/other/other_apis.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
from ..utils import commons
44
from ..utils.requests import Requests as requests
5+
import json
56

67
# --- Front page ---
8+
79
def get_news(*, limit=10, offset=0):
810
return commons.api_iterative("https://api.scratch.mit.edu/news", limit = limit, offset = offset)
911

@@ -100,6 +102,17 @@ def aprilfools_get_counter() -> int:
100102
def aprilfools_increment_counter() -> int:
101103
return requests.post("https://api.scratch.mit.edu/surprise")["surprise"]
102104

105+
# --- Miscellaneous ---
106+
107+
# I'm not sure what to label this as
108+
def scratch_team_members() -> dict:
109+
text = requests.get("https://scratch.mit.edu/js/credits.bundle.js").text
110+
text = "[{\"userName\"" + text.split("('[{\"userName\"")[1]
111+
text = text.split( "\"}]')")[0] + "\"}]"
112+
113+
return json.loads(text)
114+
115+
103116
# --- Resources ---
104117
def get_resource_urls():
105118
return requests.get("https://resources.scratch.mit.edu/localized-urls.json").json()

0 commit comments

Comments
 (0)