Advertisement
Guest User

passar per tota la VP

a guest
Apr 30th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         for arg in args:
  25.             if arg.startswith("-ini:"):
  26.                 inici=arg[arg.index(":")+1:]
  27.         if inici:
  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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement