Skip to content

Instantly share code, notes, and snippets.

@ninjamar
Last active December 5, 2021 00:12
Show Gist options
  • Select an option

  • Save ninjamar/bf76adcca78e66153068a155766c4a97 to your computer and use it in GitHub Desktop.

Select an option

Save ninjamar/bf76adcca78e66153068a155766c4a97 to your computer and use it in GitHub Desktop.
Scratch User Status
import re
import requests
user = 'ninjamar'
r = requests.get(f'https://scratch.mit.edu/users/{user}')
c = ''.join([i.decode().strip() for i in r.iter_lines()])
iscratcher = re.compile("<span class=\"group\">Scratcher</span>")
isscratchteam = re.compile("<span class=\"group\">Scratch Team</span>")
isnewscratcher = re.compile("<span class=\"group\">New Scratcher</span>")
if iscratcher.search(c):
print(f'{user} is a scratcher')
elif isscratchteam.search(c):
print(f'{user} is on the scratch team')
elif isnewscratcher.search(c):
print(f'{user} is a new scratcher')
@ninjamar
Copy link
Author

ninjamar commented Dec 5, 2021

The code doesn't seem to be replacing all occurrences of \n,\t,' ' with ``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment