27 lines
938 B
Python
27 lines
938 B
Python
|
|
import urllib.request
|
||
|
|
import json
|
||
|
|
|
||
|
|
url = "https://api.osf.io/v2/users/me/nodes/"
|
||
|
|
req = urllib.request.Request(url, headers={"Authorization": "Bearer BYnPaAb6kZN7r3dz0F1rrLS1ksXwl5zoGPD4L2aS22HAosABsIMOMHqnxfO5neh0AKioVO"})
|
||
|
|
try:
|
||
|
|
with urllib.request.urlopen(req) as response:
|
||
|
|
data = json.loads(response.read().decode())
|
||
|
|
nodes = data.get("data", [])
|
||
|
|
if not nodes:
|
||
|
|
print("No nodes found.")
|
||
|
|
for n in nodes:
|
||
|
|
attr = n.get("attributes", {})
|
||
|
|
nid = n.get("id")
|
||
|
|
title = attr.get("title")
|
||
|
|
pub = attr.get("public")
|
||
|
|
cat = attr.get("category")
|
||
|
|
date = attr.get("date_created")
|
||
|
|
print(f"ID: {nid}")
|
||
|
|
print(f"Title: {title}")
|
||
|
|
print(f"Public: {pub}")
|
||
|
|
print(f"Category: {cat}")
|
||
|
|
print(f"Created: {date}")
|
||
|
|
print("-" * 40)
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error: {e}")
|