forked from gil9red/SimplePyScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_user_github_info.py
More file actions
83 lines (63 loc) · 3.27 KB
/
Copy pathget_user_github_info.py
File metadata and controls
83 lines (63 loc) · 3.27 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from grab import Grab
"""Скрипт, используя логин и пароль, авторизовывается в github, после выводит
информацию о пользователе.
"""
__author__ = 'ipetrash'
if __name__ == '__main__':
login = input("Логин: ")
password = input("Пароль: ")
g = Grab()
# Переходим на страницу входа
print("...Перехожу на страницу входа...")
g.go("https://github.com/login")
# Заполняем формы логина и пароля
print("...Заполняю формы логина и пароля...")
g.set_input("login", login)
g.set_input("password", password)
# Отсылаю данные формы
print("...Отсылаю данные формы...")
g.submit()
# Переход на страницу пользователя
print("...Перехожу на страницу пользователя...")
g.go("https://github.com/" + login)
# Получение информации с страницы пользователя
print("...Получаю информацию с страницы пользователя...")
fullname = g.doc.select('//span[@itemprop="name"]').text()
username = g.doc.select('//span[@itemprop="additionalName"]').text()
avatar = g.doc.select('//*[@class="vcard-avatar tooltipped tooltipped-s"]/*[@class="avatar"]').attr('src')
organization = g.doc.select('//li[@itemprop="worksFor"]').text()
homeLocation = g.doc.select('//li[@itemprop="homeLocation"]').text()
email = g.doc.select('//a[@class="email"]').text()
url = g.doc.select('//li[@itemprop="url"]').text()
join_label = g.doc.select('//span[@class="join-label"]').text()
join_title_time = g.doc.select('//time[@class="join-date"]').text()
join_datetime = g.doc.select('//time[@class="join-date"]').attr("datetime")
print()
print("full name:", fullname)
print("user name:", username)
print("avatar:", avatar)
print("organization:", organization)
print("home location:", homeLocation)
print("email:", email)
print("url:", url)
print('{} {} ({})'.format(join_label, join_title_time, join_datetime))
# Получение списка репозиториев
print()
print('...Перехожу на вкладку репозиториев...')
g.go("https://github.com/" + login + '?tab=repositories')
print("...Получаю список репозиториев...")
list_source_repo = g.doc.select('//li[@class="repo-list-item public source"]')
print()
print("Репозитории:")
print("Sources({}):".format(len(list_source_repo)))
for i, repo in enumerate(list_source_repo, 1):
name = repo.select('*[@class="repo-list-name"]/a')
href = 'https://github.com' + name.attr('href')
print(' {}. {}: {}'.format(i, name.text(), href))
description = repo.select('*[@class="repo-list-description"]')
if description.count():
print(' "{}"'.format(description.text()))
stats = repo.select('*[@class="repo-list-stats"]').text().split(' ')
lang, stars, forks = stats
print(' lang: {}, stars: {}, forks: {}'.format(lang, stars, forks))
print()