-
Notifications
You must be signed in to change notification settings - Fork 2
/
fr.n.wikidata.py
executable file
·41 lines (36 loc) · 1.12 KB
/
fr.n.wikidata.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
#!/usr/bin/env python
# coding: utf-8
import pywikibot
site = pywikibot.Site("fr", "wikinews")
def modification(PageHS):
try:
page = pywikibot.Page(site, PageHS)
except NoPage:
print "NoPage"
return
except IsRedirectPage:
print "Redirect page"
return
except LockedPage:
print "Locked/protected page"
return
# Données Wikidata (https://www.wikidata.org/wiki/Wikidata:Creating_a_bot/fr)
try:
item = pywikibot.ItemPage.fromPage(page) # AttributeError: 'module' object has no attribute 'ItemPage'
except AttributeError:
print "AttributeError"
return
dictionary = item.get()
print dictionary
print dictionary.keys()
print item
# Liens interwikis
'''repo = site.data_repository()
item = pywikibot.ItemPage(repo, u"Q42")
item.get()
print item.sitelinks'''
modification(u"Burkina Faso : l'armée prend le pouvoir après une journée d'émeutes")
modification(u'Catégorie:Pages non indexées')
modification(u"Burkina Faso : l'armée prend le pouvoir après une journée d'émeutes")
modification(u'Catégorie:Pages non indexées')
#modification(u'Wikinews:Salle café/2014/septembre')