This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
LabyStudio's profile picture

[Youtube] Subscribers counter [solved]

Started by LabyStudio, 13 July 2013 - 07:33 AM
LabyStudio #1
Posted 13 July 2013 - 09:33 AM
[Youtube] Subscribers counter

solved.

-- code by Bubba
local page = http.get("http://www.youtube.com/channel/NAME") --#Some channel
local text = page.readAll()
print("Subscribers -> "..text:match([[subscribed"%s->([^<]*)]]))
Zudo #2
Posted 13 July 2013 - 10:40 AM
Would this help?
https://developers.google.com/youtube/
LabyStudio #3
Posted 13 July 2013 - 10:47 AM

yes, but I don't understand how I let it show only the subscribers
Grim Reaper #4
Posted 13 July 2013 - 05:45 PM
Apparently, you'll need to register your application with Google if you want to use their client-side API for interaction with your YouTube account. However, you could probably just download the page-source for a YouTube account and parse out the subscription count.
Bubba #5
Posted 13 July 2013 - 11:15 PM
It's pretty simple if all you need is the subscribed amount. If you take a look in the source code of the page, you'll see something like this:

<span class="yt-subscription-button-subscriber-count-branded-horizontal subscribed">36</span>

So get the page text and run a simple regex match on it:

local page = http.get("http://www.youtube.com/channel/UC83CJDRvam3_3VKK2L52x9g") --#Some channel
local text = page.readAll()
print("Subscribers -> "..text:match([[subscribed"%s->([^<]*)]]))

Which will print out: "Subscribers -> 36"
LabyStudio #6
Posted 15 July 2013 - 10:27 AM
It's pretty simple if all you need is the subscribed amount. If you take a look in the source code of the page, you'll see something like this:

<span class="yt-subscription-button-subscriber-count-branded-horizontal subscribed">36</span>

So get the page text and run a simple regex match on it:

local page = http.get("http://www.youtube.com/channel/UC83CJDRvam3_3VKK2L52x9g") --#Some channel
local text = page.readAll()
print("Subscribers -> "..text:match([[subscribed"%s->([^<]*)]]))

Which will print out: "Subscribers -> 36"

thank you;)