Created
September 14, 2011 10:55
-
-
Save Pet3ris/1216305 to your computer and use it in GitHub Desktop.
Quick & dirty meetup list parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
content = open('./Desktop/meetup list.htm', 'r').read() | |
members = re.findall('<tr id="mem.*?</tr>', content, re.DOTALL) | |
people = [] | |
count = 0 | |
for member in members: | |
if len(re.findall('<span class="D_yes">Yes</span>', member)) > 0: | |
m = re.search(r'<span class="D_name">(?P<name>[^\n]*)', member, re.U) | |
name = m.group('name') | |
m = re.search(r'<dt><strong>Your email address:</strong></dt>\n+<dd>(?P<email>[^<]+)<', member, re.U) | |
if m: | |
email = m.group('email') | |
else: | |
email = '' | |
people.append((name, email)) | |
ppl = sorted(people, key = lambda x: x[0]) | |
output = '' | |
for name, email in ppl: | |
output += name + ' ' + email + '\n' | |
open('list.txt', 'w').write(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment