scratchattach
scratchattach copied to clipboard
Add way to get parent_id for profile comments
It would be beneficial to have this feature implemented.
from bs4 import BeautifulSoup
import requests
def find_parent_id(comment_id, user):
try:
i = 0
while True:
data = requests.get(
f"https://scratch.mit.edu/site-api/comments/user/{user}/?page=" + str(i)).text
soup = BeautifulSoup(data, features="html.parser")
comment = soup.find(id="comments-" + str(comment_id))
if comment != None:
return comment.parent.parent.parent.find(class_="comment")["data-comment-id"]
break
i += 1
except AttributeError:
return comment_id
I know about that and TimMcCool likely also does. I am just suggesting it be implemented.
Okay, I agree it should be good to implement :D