Skip to content

Commit f421a90

Browse files
author
Hau Chong
committed
Github-Follower-Bot initial commit
1 parent 028174e commit f421a90

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed

Github-Follower-Bot/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Github Follower Bot
2+
3+
## Setup instructions
4+
- Have Python 3 installed
5+
- pip install selenium
6+
- Download webdriver for your respective browsers
7+
- Open up config.py and enter your github username and password and save it.
8+
- To configure your search target, edit the name list.
9+
- To configure how many pages you want to traverse, edit the range(1, your_desired_number)
10+
- Finally, fire up the console in root directory of this repo and key in `python main.py` then press enter.
11+
12+
## Witness the webdriver come to live!
13+
14+
### NOTE
15+
* Please do not abuse this bot, you might be forced to unfollow everyone.
16+
* In this case, simply change in @arial-label parameter, replace Follow with Unfollow.
Binary file not shown.

Github-Follower-Bot/chromedriver.exe

8.62 MB
Binary file not shown.

Github-Follower-Bot/config.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Github username here
2+
GITHUB_USER = "username"
3+
# Github password here
4+
GITHUB_PASS = "password"

Github-Follower-Bot/main.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from selenium import webdriver
2+
from selenium.webdriver.common.keys import Keys
3+
from config import GITHUB_USER, GITHUB_PASS
4+
import time
5+
import sys
6+
7+
# Initialize chrome webdriver
8+
driver = webdriver.Chrome()
9+
10+
driver.get('https://github.com/login')
11+
# Login field is id='login_field' & password field is 'password'
12+
username = driver.find_element_by_id('login_field')
13+
password = driver.find_element_by_id('password')
14+
15+
# Key in <input> fields
16+
username.send_keys(GITHUB_USER)
17+
time.sleep(1)
18+
password.send_keys(GITHUB_PASS)
19+
time.sleep(1)
20+
21+
# Automate click on login button
22+
press_login = driver.find_element_by_xpath("//input[@value='Sign in']")
23+
time.sleep(1)
24+
press_login.click()
25+
time.sleep(1)
26+
27+
# Specify any name you want to be honest
28+
name_list = ['john', 'tom', 'jump']
29+
30+
# Search for users
31+
# Search via best match url='https://github.com/search?o={}&q=user&s=&type={}'
32+
# We want to use type=Users you can use other types as well
33+
34+
for name in name_list:
35+
for page in range(1, 100):
36+
url = 'https://github.com/search?p={}&q={}&type=Users'.format(
37+
page, name)
38+
driver.get(url)
39+
time.sleep(1)
40+
41+
# Find and press follow button
42+
follow_user = driver.find_elements_by_xpath(
43+
"//input[@aria-label='Follow this person']")
44+
45+
try:
46+
for i in follow_user:
47+
i.submit()
48+
except:
49+
pass
50+
time.sleep(1)
51+
52+
driver.close()

0 commit comments

Comments
 (0)