├── README.md ├── follow.py └── unfollow.py /README.md: -------------------------------------------------------------------------------- 1 | # github-follow-unfollow-bot 2 | This is a Python script for Github Bot which uses Selenium to Automate things. 3 | # 4 | 5 | ## Pre-requisites :- 6 | - Python 7 | - A Github Account 8 | 9 | # 10 | 11 | ## Requirements :- 12 | - In command prompt install dependancies: `pip install selenium` 13 | - Install Chrome Webdriver to automate from: [`here`](https://chromedriver.chromium.org/downloads) or any driver of your wish from Internet. 14 | 15 | ## 16 | ### And then run the scripts as: `python follow.py` or `python unfollow.py` 17 | ### Enter username and password as asked 18 | ### 19 | ### And here we go, you are all set. 20 | 21 | # 22 | 23 | ## Author: [Chaudhary Hamdan](https://chaudharyhamdan.me/) 24 | # 25 | # Thank you 26 | -------------------------------------------------------------------------------- /follow.py: -------------------------------------------------------------------------------- 1 | # Github Automatic FOLLOW bot 2 | 3 | 4 | # Author: Chaudhary Hamdan 5 | # Personal Portfolio Website: https://chaudharyhamdan.me/ 6 | # Resume: https://drive.google.com/file/d/1Vx_foSFBrgjj_zRTiNVRGxUY43O8-JXT/view 7 | # Linkedin: https://www.linkedin.com/in/chaudhary-hamdan-34ab5b1a6/ 8 | # Github link : https://github.com/hamdan-codes 9 | 10 | 11 | # Inspired from: https://github.com/andrewsyc/github-follow-bot 12 | # And Coding Ninjas Instructor for an amazing learning experience: Nidhi Agarwal Ma'am (https://www.linkedin.com/in/nidhi-agarwal-704bb05a/) 13 | 14 | # Importing libraries 15 | from selenium import webdriver # Tool for automation 16 | import time # Get time and sleep 17 | import getpass # Get input of passowrd not visible while entering 18 | 19 | # Enter your Username and Password here to login 20 | username = input('Enter you Github Username to start session: ') 21 | password = getpass.getpass('And password to start session: ') 22 | 23 | 24 | # Run our driver to initiate session 25 | # exectable_path is the path where our chrome driver is installed 26 | # Can be downloaded from the link: https://chromedriver.chromium.org/downloads 27 | driver = webdriver.Chrome(executable_path='C:/Users/KIIT/Downloads/chromedriver_win32/chromedriver.exe') 28 | 29 | # Get request to the Github URL to login 30 | driver.get('https://github.com/login') 31 | 32 | # Finding the 'Enter Username' space and sending keys to enter 33 | btn = driver.find_element_by_name('login') 34 | btn.send_keys(username) 35 | 36 | # Finding the 'Enter Password' space and sending keys to enter 37 | btn = driver.find_element_by_name('password') 38 | btn.send_keys(password) 39 | 40 | # Finding Submit button and clicking on it to finally login to your account 41 | btn = driver.find_element_by_name('commit') 42 | btn.click() 43 | 44 | # Get to your Profile page 45 | driver.get(f'https://github.com/{username}') 46 | 47 | # These are some popular usernames across whole Github 48 | # If you wish to follow all the followers of any user(s) for your choice, 49 | # just add them in the below list at the starting 50 | users = ["jashkenas", "ruanyf", "substack", "kennethreitz", "jlord", "daimajia", "mdo", "schacon", 51 | "mattt", "sindresorhus", "defunkt", "douglascrockford", "mbostock", "jeresig", "mojombo", 52 | "addyosmani", "paulirish", "vczh", "romannurik", "tenderlove", "chriscoyier", "johnpapa", 53 | "josevalim", "charliesome", "CoderMJLee", "ry", "antirez", "muan", "isaacs", "angusshire", 54 | "hadley", "hakimel", "yyx990803", "fat", "fabpot", "ibireme", "tekkub", "BYVoid", "laruence", 55 | "onevcat", "tpope", "mrdoob", "LeaVerou", "chrisbanes", "wycats", "lifesinger", "cloudwu", 56 | "mitsuhiko", "michaelliao", "ryanb", "clowwindy", "JacksonTian", "yinwang0", "Trinea", 57 | "pjhyett", "dhh", "gaearon"] 58 | 59 | # Iterating over all the usernames 60 | for user in users: 61 | 62 | # Counter to take to next -> next pages 63 | t = 0 64 | 65 | # Looping through all the followers pages of username 'user' from page 1 to last 66 | while True: 67 | 68 | # Incrementing counter to reach next page after completing task on the current page 69 | t += 1 70 | 71 | # URL for the page to load 72 | string = f"https://github.com/{user}?page={t}&tab=followers" 73 | 74 | # Requesting to the page and starting task 75 | driver.get(string) 76 | 77 | # Waiting for the page to load properly 78 | time.sleep(1) 79 | 80 | # Finding all the follow buttons present on the current page 81 | follow_buttons = driver.find_elements_by_name('commit')[0::2] # 0 -> To Follow, 1 -> To Unfollow 82 | 83 | # Condition to check if we reached the last page, if so then break 84 | if len(follow_buttons) < 25: 85 | break 86 | 87 | # Looping through al the follow buttons 88 | for button in follow_buttons: 89 | 90 | # Clicking on the buttons 91 | button.submit() 92 | 93 | # Waiting to follow and save all the users present on the page 94 | time.sleep(1) 95 | 96 | # If you wish to just do this for only the first user in the above list, user break here. 97 | #break 98 | driver.quit() 99 | -------------------------------------------------------------------------------- /unfollow.py: -------------------------------------------------------------------------------- 1 | # Github Automatic UNFOLLOW bot 2 | # To unfollow, go to the same users and its followers list and unfollow them 3 | 4 | 5 | # Author: Chaudhary Hamdan 6 | # Personal Portfolio Website: https://chaudharyhamdan.me/ 7 | # Resume: https://drive.google.com/file/d/1Vx_foSFBrgjj_zRTiNVRGxUY43O8-JXT/view 8 | # Linkedin: https://www.linkedin.com/in/chaudhary-hamdan-34ab5b1a6/ 9 | # Github link : https://github.com/hamdan-codes 10 | 11 | 12 | # Inspired from: https://github.com/andrewsyc/github-follow-bot 13 | # And Coding Ninjas Instructor for an amazing learning experience: Nidhi Agarwal Ma'am (https://www.linkedin.com/in/nidhi-agarwal-704bb05a/) 14 | 15 | # Importing libraries 16 | from selenium import webdriver # Tool for automation 17 | import time # Get time and sleep 18 | import getpass # Get input of passowrd not visible while entering 19 | 20 | # Enter your Username and Password here to login 21 | username = input('Enter you Github Username to start session: ') 22 | password = getpass.getpass('And password to start session: ') 23 | 24 | 25 | # Run our driver to initiate session 26 | # exectable_path is the path where our chrome driver is installed 27 | # Can be downloaded from the link: https://chromedriver.chromium.org/downloads 28 | driver = webdriver.Chrome(executable_path='C:/Users/KIIT/Downloads/chromedriver_win32/chromedriver.exe') 29 | 30 | # Get request to the Github URL to login 31 | driver.get('https://github.com/login') 32 | 33 | # Finding the 'Enter Username' space and sending keys to enter 34 | btn = driver.find_element_by_name('login') 35 | btn.send_keys(username) 36 | 37 | # Finding the 'Enter Password' space and sending keys to enter 38 | btn = driver.find_element_by_name('password') 39 | btn.send_keys(password) 40 | 41 | # Finding Submit button and clicking on it to finally login to your account 42 | btn = driver.find_element_by_name('commit') 43 | btn.click() 44 | 45 | # Get to your Profile page 46 | driver.get(f'https://github.com/{username}') 47 | 48 | # These are some popular usernames across whole Github 49 | # If you wish to follow all the followers of any user(s) for your choice, 50 | # just add them in the below list at the starting 51 | users = ["jashkenas", "ruanyf", "substack", "kennethreitz", "jlord", "daimajia", "mdo", "schacon", 52 | "mattt", "sindresorhus", "defunkt", "douglascrockford", "mbostock", "jeresig", "mojombo", 53 | "addyosmani", "paulirish", "vczh", "romannurik", "tenderlove", "chriscoyier", "johnpapa", 54 | "josevalim", "charliesome", "CoderMJLee", "ry", "antirez", "muan", "isaacs", "angusshire", 55 | "hadley", "hakimel", "yyx990803", "fat", "fabpot", "ibireme", "tekkub", "BYVoid", "laruence", 56 | "onevcat", "tpope", "mrdoob", "LeaVerou", "chrisbanes", "wycats", "lifesinger", "cloudwu", 57 | "mitsuhiko", "michaelliao", "ryanb", "clowwindy", "JacksonTian", "yinwang0", "Trinea", 58 | "pjhyett", "dhh", "gaearon"] 59 | 60 | # Iterating over all the usernames 61 | for user in users: 62 | 63 | # Counter to take to next -> next pages 64 | t = 0 65 | 66 | # Looping through all the followers pages of username 'user' from page 1 to last 67 | while True: 68 | 69 | # Incrementing counter to reach next page after completing task on the current page 70 | t += 1 71 | 72 | # URL for the page to load 73 | string = f"https://github.com/{user}?page={t}&tab=followers" 74 | 75 | # Requesting to the page and starting task 76 | driver.get(string) 77 | 78 | # Waiting for the page to load properly 79 | time.sleep(1) 80 | 81 | # Finding all the unfollow buttons present on the current page 82 | unfollow_buttons = driver.find_elements_by_name('commit')[1::2] # 0 -> To Follow, 1 -> To Unfollow 83 | 84 | # Condition to check if we reached the last page, if so then break 85 | if len(unfollow_buttons) < 25: 86 | break 87 | 88 | # Looping through al the unfollow buttons 89 | for button in unfollow_buttons: 90 | 91 | # Clicking on the buttons 92 | button.submit() 93 | 94 | # Waiting to follow and save all the users present on the page 95 | time.sleep(1) 96 | 97 | # If you wish to just do this for only the first user in the above list, user break here. 98 | #break 99 | driver.quit() 100 | --------------------------------------------------------------------------------