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