UNSUBSCRIBE T-SERIES & SUBSCRIBE TO PEWDIEPIE AUTOMATICALLY - BOT USING PYTHON
Hello world , I m back with a new automation bot, but this time, its time to support Felix aka PewDiePie, so I decide to make a bot that automatically unsubscribes from T-series YouTube Channel. Now, obviously this isn't going to hack into servers and all ,but you can use this in your friend's PC to make him unsub from T-Series or just do it for fun.
Before Starting the Requirements will be the same as my previous post -
Requirements :
- Selenium WebDriver (Link is given below)
- Python3
- Any Text Editor
First we'll see the code then the main explanation :
#import statements
#import statements
from time import sleep
from selenium import webdriver
#We will use this Options class to use user data of google-chrome to access
#login of the user, that is nothing but stay signed in for the automated web driver
from selenium.webdriver.chrome.options import Options
#Keys to use arrow keys here (but you can use any keys)
from selenium.webdriver.common.keys import Keys
#This part is where your user data of the google-chrome is stored, we need the user
#to first login normally in chrome and then using the cookies, session, and all that
#data which is stored in our PC (File path is mentioned below)
options = Options()
options.add_argument("user-data-dir=~/.config/google-chrome")
browser = webdriver.Chrome('./chromedriver', chrome_options=options)
#Pass the url of T-series youtube channel
#Pass the url of T-series youtube channel
browser.get('https://www.youtube.com/user/tseries/about')
#sleep(1) is used to wait for 1 second, usually done to make sure the site has been loaded properly
sleep(1)
#Now we'll click on unsubscribe button (if you want to see what id it has check below)
#Now we'll click on unsubscribe button (if you want to see what id it has check below)
unSub = browser.find_element_by_id('subscribe-button')
unSub.click()
sleep(2)
#Then after clicking on the unsubscribe button, we see a dialog box saying 'Are you sure?' so ,we'll #click on ok button
#Then after clicking on the unsubscribe button, we see a dialog box saying 'Are you sure?' so ,we'll #click on ok button
confirm = browser.find_element_by_id('confirm-button')
confirm.click()
sleep(5)
#Now we'll visit pewdiepie's channel and click on subscribe
browser.get('https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw')
Sub = browser.find_element_by_id(
'subscribe-button')
Sub.click()
#Now we'll visit pewdiepie's channel and click on subscribe
browser.get('https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw')
Sub = browser.find_element_by_id(
'subscribe-button')
Sub.click()
browser.close()
Windows 7, 8.1, and 10:
Mine is linux, so all the linux users this arugment will be the same
IMPORTANT :
For options.add_argument() see this ,
Windows 7, 8.1, and 10:
C:\Users\<username>\AppData\Local\Google\Chrome\User Data\Default
Mac OS X El Capitan:
Mac OS X El Capitan:
Users/<username>/Library/Application Support/Google/Chrome/Default Linux:/home/<username>/.config/google-chrome/defaultchange the <username> to whatever is your PC usernameMine is linux, so all the linux users this arugment will be the same
but for windows user copy paste this
WEB SCRAPPING
See the id of subscribed button has id = 'subscribe-button'
SUMMARY:
- So what we have done is , we have first logged in to the browser(done before you run this program, only once is enough if you don’t log out).
- So now you goto the T-series channel and then click on unsubscribe button and then we clicked on the confirmation OK button.
- Then you just run this program, but make sure chromedriver is still in your current working directory.
Thank you for reading :)
Here’s link to my previous blog, which will help you install this selenium webdriver and automation:



Explained in the best possible way ✨😍
ReplyDeleteThank you so much bro, grateful ❤️❤️❤️✨👀
Delete