-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathalumni_data.py
More file actions
48 lines (34 loc) · 852 Bytes
/
alumni_data.py
File metadata and controls
48 lines (34 loc) · 852 Bytes
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
#!/usr/local/bin/python3
import common
import pywikibot
import wikitextparser as parser
from pywikibot import pagegenerators
PROP_ID = 'P69'
CAT = 'Ahmadu Bello University alumni'
LIST_PAGE = 'List_of_Ahmadu_Bello_University_alumni'
wiki = pywikibot.Site('en', 'wikipedia')
def main():
pages = get_pages()
for page in pages:
pass
def get_pages():
page = pywikibot.Page(wiki, LIST_PAGE)
parsed = parser.parse(page.text)
listItems = parsed.get_lists()
pages = list()
lines = list()
for index in range(0, len(listItems)):
items = listItems[index]
lines.extend(items.items)
for line in lines:
title = parser.parse(line)
links = title.wikilinks
if not links:
continue
title = links[0].title
page = pywikibot.Page(wiki, title)
if page.exists:
pages.append(title)
return pages
if __name__ == '__main__':
main()