# Copyright (C) 2010 Bonacina Alberto # # listArchPack is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # listArchPack is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Keep; if not, write to the # Free Software Foundation, Inc., # 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. import urllib; import urllister; import csv,time; #definisco la lista che deve contenere tutti i file con il percorso allPackage = [] # definisco l'URL da cui dovro' andare a scaricare il file #repoBase = "http://mirrors.kernel.org/archlinux/" repoBase = raw_input("Inserire il repository da cui estrarre le informazioni: ") arch = raw_input("Inserisci l'architettura del tuo sistema [i686/x86_64]: ") while (arch!="i686")&(arch!="x86_64"): arch = raw_input("Inserisci l'architettura del tuo sistema [i686/x86_64]: ") def listPackage(url,arch,finWrite): #salvo la pagina html da cui devo estrarre i valori tempHtml = urllib.urlopen(url) #inizializzo il parser che deve analizzare il file tempHtml tempParser = urllister.URLLister() #leggo il file tempHtml tempParser.feed(tempHtml.read()) tempHtml.close() tempParser.close() for el in tempParser.urls: if (el.find("pkg.tar.gz") | el.find("pkg.tar.xz")) & (el.find(arch+".")!=(-1)): print url + el finWrite.writerow([url+el,str(time.time())]) if (el.find("/")!=(-1)) & (el!="/") & ((url + el).count(el)<2): listPackage(url + el,arch,finWrite) ########################Main############# finWrite = csv.writer(open("listPackage.csv","wb")) listPackage(repoBase,arch,finWrite)