Skip to content

Instantly share code, notes, and snippets.

@lae
Created March 29, 2017 21:27
Show Gist options
  • Save lae/603414f61275223c817ac1a118d5c7d2 to your computer and use it in GitHub Desktop.
Save lae/603414f61275223c817ac1a118d5c7d2 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import requests
import re
import sys
from collections import Counter
if len(sys.argv) < 2:
sys.exit("usage: python {} player-id".format(sys.argv[0]))
ranking_pl = requests.get("http://arcturus.su/tenhou/ranking/ranking.pl?name={}".format(sys.argv[1]))
re_points = re.compile('\([+-]\d+\\.\d\)')
opponents = []
for line in ranking_pl.text.split('\n'):
# Identifies the non-interesting lines and ignores them
if not line.endswith(')<br>'):
continue
match = [c.strip().replace('<br>', '') for c in line.split(' | ')]
room = match[1]
play_format = match[5]
for opponent in re_points.sub('', match[8]).split():
if opponent != sys.argv[1] and room == 'L0000' and play_format.startswith('四'):
opponents.append(opponent)
counts = Counter(opponents).most_common()
for count in counts[::-1]:
print("{:3d}: {}".format(count[1], count[0]))
print("{:d} total games".format(int(len(opponents)/3)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment