rendered paste body#!/usr/bin/python#encoding: utf8import re, sys, urllib, timedef fetch_page(num): sock = urllib.urlopen('http://www.habrahabr.ru/people/page%d/' % num) html = sock.read().decode('CP1251') sock.close() return htmldef grep_users(page): p = re.compile(u'.*<!--- / ВЫВОД ПОЛЬЗОВАТЕЛЕЙ --->.*<!--- ВЫВОД ПОЛЬЗОВАТЕЛЕЙ --->(.*)<!--- / ВЫВОД ПОЛЬЗОВАТЕЛЕЙ --->.*<!--- / ВЫВОД ПОЛЬЗОВАТЕЛЕЙ --->.*', re.DOTALL | re.UNICODE); m = p.match(page) if m: ucode = m.group(1) else: return [] u = re.compile('.*<td width="10%" align="center">(.*)</td>.*', re.UNICODE) return u.findall(ucode)users = []for i in range(1, 117): users = grep_users(fetch_page(i)) + users; sys.stderr.write('Page %d processed; Total users found: %d\n' % (i, len(users))) time.sleep(5)c = 0output = u''for u in users: c = c + 1 output = output + u if c > 21: output = output + '<br/>' c = 0