-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdataCollectionCorrected.py
56 lines (47 loc) · 1.53 KB
/
dataCollectionCorrected.py
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
53
54
55
56
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import TimeoutException
import time
import re,getpass,csv
import datetime
import random
def screenpos():
driver.set_window_size(4031,1031)
driver.set_window_position(-8,0)
time.sleep(1)
PATH = "chromedriver"
# PATH = "/home/captain/Social Networks/Soical Project/Data Collection/chromedriver"
with open("data.txt") as f:
lines = f.read().splitlines()
data = open("DataCorrect.txt","a")
check = 0
for users in lines:
check += 1
if(check<1620):
continue
print(check)
repos = []
users = users.split()
data.write('\n')
user = users[0]
data.write(user)
path = "https://github.com/"+user+"?tab=repositories"
driver = webdriver.Chrome(PATH)
driver.minimize_window()
driver.implicitly_wait(1)
driver.get(path)
try:
user_repos = WebDriverWait(driver,5).until(
EC.presence_of_all_elements_located((By.CSS_SELECTOR, '#user-repositories-list > ul > li > div.col-10.col-lg-9.d-inline-block > div.d-inline-block.mb-1 > h3 > a')),
)
for repo in user_repos:
data.write(" "+repo.text)
repos.append(repo.text)
except TimeoutException:
pass
print(repos)
driver.quit()