import urllib verb = 'ListRecords' mdPrefix = 'oai_lom' host = 'http://opah:8080/WaramuWeb/OAIHandler' #host = 'http://ait.opetaja.ee/WaramuWeb/OAIHandler' url = host+'?verb='+verb+'&metadataPrefix='+mdPrefix print url u = urllib.urlopen(url) data = u.read() import cElementTree xml = cElementTree.fromstring(data) print "50" c = 50 rt = xml.find('{http://www.openarchives.org/OAI/2.0/}ListRecords/{http://www.openarchives.org/OAI/2.0/}resumptionToken') token = rt.text while token != None: url = host+'?verb='+verb+'&resumptionToken='+token u = urllib.urlopen(url) data = u.read() xml = cElementTree.fromstring(data) recs = xml.findall('{http://www.openarchives.org/OAI/2.0/}ListRecords/{http://www.openarchives.org/OAI/2.0/}record') print len(recs) c += len(recs) rt = xml.find('{http://www.openarchives.org/OAI/2.0/}ListRecords/{http://www.openarchives.org/OAI/2.0/}resumptionToken') if rt is not None: token = rt.text else: token = None print "All done. Total:", c