MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / loves_count

Method loves_count

scratchattach/site/user.py:681–695  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

679 return _projects
680
681 def loves_count(self):
682 with requests.no_error_handling():
683 text = requests.get(
684 f"https://scratch.mit.edu/projects/all/{self.username}/loves/",
685 headers=self._headers,
686 ).text
687
688 # If there are no loved projects, then Scratch doesn't actually display the number - so we have to catch this
689 soup = BeautifulSoup(text, "html.parser")
690
691 if not soup.find("li", {"class": "project thumb item"}):
692 # There are no projects, so there are no projects loved
693 return 0
694
695 return commons.webscrape_count(text, "»\n\n (", ")")
696
697 def favorites(self, *, limit=40, offset=0):
698 """

Callers 1

test_userFunction · 0.80

Calls 3

no_error_handlingMethod · 0.45
getMethod · 0.45
findMethod · 0.45

Tested by 1

test_userFunction · 0.64