Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import re
- team_re = re.compile('<td class="party">(.*?)</td>')
- data = open("standings.html").read()
- seen_uni = set()
- replacements = set()
- data = data.replace('../standings-wt.css','http://neerc.ifmo.ru/standings-wt.css')
- c = 0
- for match in team_re.finditer(data):
- match = match.groups()[0]
- uni, team = match.rsplit('(', 1)
- uni, team = uni.strip(), '(' + team
- su = uni[:-1] if uni[-1].isdigit() else uni
- if su in seen_uni:
- replacements.add((match, '<del>%s</del>' % match))
- else:
- c += 1
- replacements.add((match, '<b>%d:</b> %s' % (c, match)))
- seen_uni.add(su)
- for x, y in replacements:
- data = data.replace('<td class="party">%s</td>' % x, '<td class="party">%s</td>' % y)
- with open("standings-unique.html", "wb") as f:
- f.write(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement