←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

[Youtube] Subscribers counter [solved]

LabyStudio's Photo LabyStudio 13 Jul 2013

[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->([^<]*)]]))
Quote

Zudo's Photo Zudo 13 Jul 2013

Would this help?
https://developers.google.com/youtube/
Quote

LabyStudio's Photo LabyStudio 13 Jul 2013

 ZudoHackz, on 13 July 2013 - 09:40 AM, said:


yes, but I don't understand how I let it show only the subscribers
Quote

Grim Reaper's Photo Grim Reaper 13 Jul 2013

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.
Quote

Bubba's Photo Bubba 13 Jul 2013

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"
Quote

LabyStudio's Photo LabyStudio 15 Jul 2013

 Bubba, on 13 July 2013 - 10:15 PM, said:

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;)
Quote