View difference between Paste ID: vKM2BXfE and KdzynjQH
SHOW: | | - or go back to the newest paste.
1
# -*- coding: utf-8  -*-
2
import sys, os
3
path = os.path.join(os.path.split(os.getcwd())[:-1][0])
4
sys.path.append(path)
5
import wikipedia as pywikilib, pagegenerators as pg
6
7
def revisar_tota_la_Viqui(inici="!"):
8
9
	gen = pg.AllpagesPageGenerator(start=inici, namespace=0, includeredirects=False)
10
	all_pages = pg.PreloadingGenerator(gen, pageNumber = 50)
11
	try:
12
		for page in gen:
13
			#anirà passant totes els articles de cawiki com a objectes Page()
14
			pywikilib.output(page.title())
15
			#aquí podria anar la funció que vulgueres
16
			#funcio(page)
17
	except KeyboardInterrupt:
18
		raise KeyboardInterrupt("cancelled by user")
19
20
if __name__ == '__main__':
21
	args = pywikilib.handleArgs()
22
	try:
23
		inici=None
24-
				inici=arg[arg.index(":"):]
24+
25-
		pywikilib.output(u"comencem per: [[%s]]" % inici)
25+
26-
		revisar_tota_la_Viqui(inici)
26+
				inici=arg[arg.index(":")+1:]
27
		if inici:
28-
		pywikilib.output(u"cancel·lat per l'usuari")
28+
			pywikilib.output(u"comencem per: [[%s]]" % inici)
29
			revisar_tota_la_Viqui(inici)
30
		else:
31
			revisar_tota_la_Viqui()
32
	except KeyboardInterrupt:
33
		pywikilib.output(u"\3{lightred}cancel·lat per l'usuari\3{default}")
34
	finally:
35
		pywikilib.stopme()