#!/usr/bin/env python import re r_ra = re.compile(r'_RAJ2000([+-]?\d+) ([+-]?\d+)') r_dec = re.compile(r'_DEJ2000([+-]?\d+) ([+-]?\d+)') out = open('LBN.txt', 'w') print >> out, 'i, ra, dec' for i in xrange(1, 1126): f = open(str(i) + '.html') for line in f: m = r_ra.search(line) if m: ra = m.group(1) + ':' + m.group(2) n = r_dec.search(line) if n: dec = n.group(1) + ':' + n.group(2) print >> out, i, ra, dec f.close()