Discuss Scratch

-Snipet-
Scratcher
500+ posts

Scratch API get Total Follower Count

Basically what the title says. I know how to get the followers of a particular user, but it just shows a few. How do I get the total amount?

website =)
Blasted little 60 second rule…
_nix
Scratcher
1000+ posts

Scratch API get Total Follower Count

There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on the user's /followers/ page.

══ trans autistic lesbian enbydoggirls // 16 17 18 19 20 21, she/they
sparrows one word to the paragraph // <3 // ~(quasar) nebula
-Snipet-
Scratcher
500+ posts

Scratch API get Total Follower Count

_nix wrote:

There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on the user's /followers/ page.
Oh yeah. I completely overlooked that. Thanks!

Last edited by -Snipet- (March 24, 2019 18:18:38)


website =)
Blasted little 60 second rule…
-Bonfire-
Scratcher
59 posts

Scratch API get Total Follower Count

-Snipet- wrote:

_nix wrote:

There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on the user's /followers/ page.
Oh yeah. I completely overlooked that. Thanks!
You could make one yourself

-Bonfire- can code
Movies22_by_TR
Scratcher
19 posts

Scratch API get Total Follower Count

_nix wrote:

There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on the user's /followers/ page.
well, i tried doing that using node-fetch, but i got a empty response:
<html><head></head><body></body></html>
. How can i parse the HTML then?

———————-
Movies22
when [ Welcome] key pressed
say [Hi]

My YT channel.
_nix
Scratcher
1000+ posts

Scratch API get Total Follower Count

Movies22_by_TR wrote:

_nix wrote:

There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on the user's /followers/ page.
well, i tried doing that using node-fetch, but i got a empty response:
<html><head></head><body></body></html>
. How can i parse the HTML then?
Huh, that's really weird! It definitely didn't error like that for me in the past, and looking at the code for other libraries for interfacing with Scratch, I don't see anything different. (I tested myself and got the same response.)

Apparently api.scratch.mit.edu still works fine, so you could try using that. It (still) doesn't have a follow count directly accessible anywhere, but you can calculate it by making repeated requests at different follower offsets to narrow in on the precise count.

E.g, make a number of requests like this:

  1. https://api.scratch.mit.edu/users/_nix/followers/?offset=0&limit=40
    Response array length is full (40 items, max length for API) so there are more than 40 followers.
  2. https://api.scratch.mit.edu/users/_nix/followers/?offset=40&limit=40
    Length is 40 so there are more than 80 followers.
  3. https://api.scratch.mit.edu/users/_nix/followers/?offset=80&limit=40
    Length is 40 so there are more than 120 followers.
  4. https://api.scratch.mit.edu/users/_nix/followers/?offset=160&limit=40
    Length is 40 so there are more than 180 followers.
  5. https://api.scratch.mit.edu/users/_nix/followers/?offset=320&limit=40
    Length is 40 so there are more than 360 followers.
  6. https://api.scratch.mit.edu/users/_nix/followers/?offset=640&limit=40
    Length is 0 so there are less than 640 followers—we've overshot, so start counting down. Halfway between 360 and 640 is 500…
  7. https://api.scratch.mit.edu/users/_nix/followers/?offset=500&limit=40
    Length is 40 so there are more than 540 followers. Just count up from here since we must be pretty close.
  8. https://api.scratch.mit.edu/users/_nix/followers/?offset=540&limit=40
    Length is 8 so there are precisely 540 + 8 = 548 followers.

…Okay, so, 548 is more than what it says on my profile, but it is exactly what is shown when I delete my account (“You joined the Scratch community 5 years ago. You've created 907 projects and have 548 followers.”), so yaknow (I think deleted accounts are included? I haven't researched this carefully.)

I definitely didn't use the most generally efficient algorithm here, but in general this will always take at least a few requests (more for accounts with more followers), so make sure you're appropriately rate limiting yourself (like only making 5 requests a second for example). Otherwise you risk getting in trouble for overloading the Scratch APIs.

Last edited by _nix (Jan. 2, 2022 19:47:45)


══ trans autistic lesbian enbydoggirls // 16 17 18 19 20 21, she/they
sparrows one word to the paragraph // <3 // ~(quasar) nebula
mybearworld
Scratcher
1000+ posts

Scratch API get Total Follower Count


Signatures are the only place where assets links still work.
ScolderCreations
Scratcher
1000+ posts

Scratch API get Total Follower Count

mybearworld wrote:

That makes sense, the reason is probably to prevent bots from spamming those pages with requests.

Movies22_by_TR
Scratcher
19 posts

Scratch API get Total Follower Count

_nix wrote:

Movies22_by_TR wrote:

_nix wrote:

There is no API for this (though they might add one eventually). For now the only way to get the follower count of a user is to parse the HTML to find the number on the user's /followers/ page.
well, i tried doing that using node-fetch, but i got a empty response:
<html><head></head><body></body></html>
. How can i parse the HTML then?
Huh, that's really weird! It definitely didn't error like that for me in the past, and looking at the code for other libraries for interfacing with Scratch, I don't see anything different. (I tested myself and got the same response.)

Apparently api.scratch.mit.edu still works fine, so you could try using that. It (still) doesn't have a follow count directly accessible anywhere, but you can calculate it by making repeated requests at different follower offsets to narrow in on the precise count.

E.g, make a number of requests like this:

  1. https://api.scratch.mit.edu/users/_nix/followers/?offset=0&limit=40
    Response array length is full (40 items, max length for API) so there are more than 40 followers.
  2. https://api.scratch.mit.edu/users/_nix/followers/?offset=40&limit=40
    Length is 40 so there are more than 80 followers.
  3. https://api.scratch.mit.edu/users/_nix/followers/?offset=80&limit=40
    Length is 40 so there are more than 120 followers.
  4. https://api.scratch.mit.edu/users/_nix/followers/?offset=160&limit=40
    Length is 40 so there are more than 180 followers.
  5. https://api.scratch.mit.edu/users/_nix/followers/?offset=320&limit=40
    Length is 40 so there are more than 360 followers.
  6. https://api.scratch.mit.edu/users/_nix/followers/?offset=640&limit=40
    Length is 0 so there are less than 640 followers—we've overshot, so start counting down. Halfway between 360 and 640 is 500…
  7. https://api.scratch.mit.edu/users/_nix/followers/?offset=500&limit=40
    Length is 40 so there are more than 540 followers. Just count up from here since we must be pretty close.
  8. https://api.scratch.mit.edu/users/_nix/followers/?offset=540&limit=40
    Length is 8 so there are precisely 540 + 8 = 548 followers.

…Okay, so, 548 is more than what it says on my profile, but it is exactly what is shown when I delete my account (“You joined the Scratch community 5 years ago. You've created 907 projects and have 548 followers.”), so yaknow (I think deleted accounts are included? I haven't researched this carefully.)

I definitely didn't use the most generally efficient algorithm here, but in general this will always take at least a few requests (more for accounts with more followers), so make sure you're appropriately rate limiting yourself (like only making 5 requests a second for example). Otherwise you risk getting in trouble for overloading the Scratch APIs.
Well, there is no way to do it easly/fast. Because i was working in a live followers counter and I needed to get the followers count of every second.

———————-
Movies22
when [ Welcome] key pressed
say [Hi]

My YT channel.
god286
Scratcher
1000+ posts

Scratch API get Total Follower Count

Movies22_by_TR wrote:

Well, there is no way to do it easly/fast. Because i was working in a live followers counter and I needed to get the followers count of every second.
Webscraping could be an option.
document.querySelector(".box-head > h2:nth-child(2)").innerText // me » Followers (12345)"

Here are some of my followers!

I joined: 5 years, 9 months, 24 days ago (31/03/2018)
I have: 479 followers
In total, I have attained: 1,403 loves, 1,145 favourites, and 33,731 views.
Fun Fact: If my account continued to gain followers at a similar rate to right now, in 14,210 years I would reach the number of followers griffpatch has today! Try to imagine how many followers he would have then!
Thank you everyone!
Script created by god286.
Wetbikeboy2500
Scratcher
100+ posts

Scratch API get Total Follower Count

god286 wrote:

Movies22_by_TR wrote:

Well, there is no way to do it easly/fast. Because i was working in a live followers counter and I needed to get the followers count of every second.
Webscraping could be an option.
document.querySelector(".box-head > h2:nth-child(2)").innerText // me » Followers (12345)"

This is for the top of the followers page where it displays the total number of followers a user has. This makes it a single request.

You can then use some regex on it to extract the specific number

/\((\d+)\)/g.exec(document.querySelector('.box-head h2').innerText)[1]



Last edited by Wetbikeboy2500 (Jan. 4, 2022 19:58:31)


Scratch Made In JavaScript: https://scratch.mit.edu/discuss/topic/171842
Scratch Browser: https://scratch.mit.edu/discuss/topic/285957/
SB2Downloader: https://scratch.mit.edu/discuss/topic/295425/
Multiple work stations: https://scratch.mit.edu/discuss/topic/122484/
New Blocks for Displaying Text: https://scratch.mit.edu/discuss/topic/171508
Sprite Folders: https://scratch.mit.edu/discuss/topic/171569/
Find code easier: https://scratch.mit.edu/discuss/topic/144748/
A Support Button or No support Button: https://scratch.mit.edu/discuss/topic/181154/
I want Scratch grow and become a better place for everyone to come and use. So Scratch needs to expand and have more options for everyone.Scratch needs to break the boundaries and not be trapped by what is familiar to Scratch community
coolcoder1213
Scratcher
100+ posts

Scratch API get Total Follower Count

ScratchDB offers the stats for the amount of followers you have but not the amount. You would have to web-scrape.

So, this is just a signature.

Scratchleton - Hamilton Mod

Cloud Stats Projects

My Profile:
coolcoder1213

I am great at cloud variables and Python.
MagicCrayon9342
Scratcher
1000+ posts

Scratch API get Total Follower Count

NFlex23
Scratcher
1000+ posts

Scratch API get Total Follower Count

MagicCrayon9342 wrote:

(#13)
You can simply grab it from the api directly. Using a CORS proxy.

Here's a list of them

A list inside a list.
Always online, fast, and free. I literally never update it, its just as cors-anywhere instance which you CAN host yourself.
I don't think you read the OP carefully. You don't even need a proxy for the Scratch API anyway.

Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
  • Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
  • The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
  • Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
  • Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
  • Issues with Scratch itself should be put in Bugs and Glitches.
Before you post: Is what you're posting likely to start an argument or derail the thread (e.g., browsers, operating systems)? If so, please re-think your post!





MagicCrayon9342
Scratcher
1000+ posts

Scratch API get Total Follower Count

NFlex23 wrote:

MagicCrayon9342 wrote:

(#13)
You can simply grab it from the api directly. Using a CORS proxy.

Here's a list of them

A list inside a list.
Always online, fast, and free. I literally never update it, its just as cors-anywhere instance which you CAN host yourself.
I don't think you read the OP carefully. You don't even need a proxy for the Scratch API anyway.
You can do it manually but a CORS proxy is just easier.

From a website you WILL need a CORS proxy or that manual method.

Steve0Greatness
Scratcher
1000+ posts

Scratch API get Total Follower Count

ScratchDB has a page for this:
https://scratchdb.lefty.one/v3/user/info/:user
this returns a JSON of info about the user in question. The total follower count is under the keys statistics, then followers.

/hj is the worst tone indicator. It's confusing and ambiguous. I hate it. The point of tone indicators is to indicate tone, or the way that a piece of text should be read, but what does “half joking” mean? Do you just wake up in the morning and think “wow, I really have something I want to talk about seriously but also kinda not, IDK you decide.” It's useless. I hate it. It just provokes a deep rooted anger within me whenever I see it. People just comment /hj as if it makes any sense. It doesn't. Oh wow, it's a tone indicator that's has a relative meaning, how useful, I'll use it in every comment I post. NO. STOP IT. You're a tone indicator, you have only one job, and yet you sit there doing nothing apart angering me.

/srs

^^^ (there's more below)
This one is useful because it tells you that this signature is fully 100% serious. (/srs) Who would've thought that tone indicators needed to tell you something about the piece of text they're attached to? /s

I'm serious, I'm not even going to put multiple (/hj)s a the end of my signature as to mock the previous paragraph for not getting the point of something(like previous version of my signature). /srs
MagicCrayon9342
Scratcher
1000+ posts

Scratch API get Total Follower Count

Steve0Greatness wrote:

ScratchDB has a page for this:
https://scratchdb.lefty.one/v3/user/info/:user
this returns a JSON of info about the user in question. The total follower count is under the keys statistics, then followers.
To clear some confusion, if you ever see a ‘:’ before a value in a URL of an express application that means that's a value to replace with the ‘user’ in this case. Not sure why everyone includes the colon as its only necessary in the code itself. Confused me at one point.

NFlex23
Scratcher
1000+ posts

Scratch API get Total Follower Count

MagicCrayon9342 wrote:

(#17)

Steve0Greatness wrote:

ScratchDB has a page for this:
https://scratchdb.lefty.one/v3/user/info/:user
this returns a JSON of info about the user in question. The total follower count is under the keys statistics, then followers.
To clear some confusion, if you ever see a ‘:’ before a value in a URL of an express application that means that's a value to replace with the ‘user’ in this case. Not sure why everyone includes the colon as its only necessary in the code itself. Confused me at one point.
It's to show people that you replace it with an arbitrary value. If you didn't include the colon it would be even more confusing.

Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
  • Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
  • The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
  • Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
  • Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
  • Issues with Scratch itself should be put in Bugs and Glitches.
Before you post: Is what you're posting likely to start an argument or derail the thread (e.g., browsers, operating systems)? If so, please re-think your post!





pyro_studios100110
Scratcher
1 post

Scratch API get Total Follower Count

hi

Powered by DjangoBB