Advertisement
Guest User

passar per tota la VP

a guest
Apr 30th, 2013
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  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.     gen = pg.AllpagesPageGenerator(start=inici, namespace=0, includeredirects=False)
  9.     try:
  10.         for page in gen:
  11.             #anirà passant totes els articles de cawiki com a objectes Page()
  12.             pywikilib.output(page.title())
  13.             #aquí podria anar la funció que vulgueres
  14.             #funcio(page)
  15.     except KeyboardInterrupt:
  16.         raise KeyboardInterrupt("cancelled by user")
  17.  
  18. if __name__ == '__main__':
  19.     args = pywikilib.handleArgs()
  20.     try:
  21.         inici=None
  22.         for arg in args:
  23.             if arg.startswith("-ini:"):
  24.                 inici=arg[arg.index(":"):]
  25.         pywikilib.output(u"comencem per: [[%s]]" % inici)
  26.         revisar_tota_la_Viqui(inici)
  27.     except KeyboardInterrupt:
  28.         pywikilib.output(u"cancel·lat per l'usuari")
  29.     finally:
  30.         pywikilib.stopme()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement