Skip to content

Scraping your Sub-count with Python (bs4,re,requests) | LBOET | HOXFRAMEWORK

Posted in VIDEOS

Scraping your Sub-count with Python (bs4,re,requests) | LBOET | HOXFRAMEWORK

Hello guys and welcome.
Lets play with some BS4 and REGEX and some Requests.
I will try my best to explain the basics of the basics of BS4 and REGEX and how to use Requests, then you can
make your own decision about what will you use. I recommend learning both.

BS4 CODE:

import requests as rq
import bs4 as bs

sauce = rq.get(‘https://www.youtube.com/channel/UCu1OkpIhOqZQI6gfi3cju_g’)
sc = sauce.content

soup = bs.BeautifulSoup(sc,’lxml’)

key = soup.find(“span”, {“class”:”yt-subscription-button-subscriber-count-branded-horizontal”})
key = key.attrs
subcount = key[“title”]

print(“Your subscriber count :”,subcount)


REGEX CODE:

import re
import requests as rq

sauce = rq.get(‘https://www.youtube.com/channel/UCu1OkpIhOqZQI6gfi3cju_g’)
sc = sauce.text

finder = re.findall(r’aria-label=\”\d*\s\w+’,sc)
converter = str(finder[0])

converter = converter.replace(“aria-label”,””)
converter = converter.replace(‘”‘,””)
converter = converter.replace(“‘]”,””)
converter = converter.replace(“pretplatnika”,””)
converter = converter.replace(“=”,””)

print(“Current subscriber count : “,converter)


Thank you so much for visiting and have a nice night :).