Skip to content

Instantly share code, notes, and snippets.

@ide-an
Created March 3, 2013 09:47
Show Gist options
  • Save ide-an/5075498 to your computer and use it in GitHub Desktop.
Save ide-an/5075498 to your computer and use it in GitHub Desktop.
BGMShareHouseに人がいるかチェック
#-*- coding: utf-8 -*-
from urllib.request import urlopen
import re
url = "http://bgmshare.vis1.shinobi.jp/js/"
s = urlopen(url).read().decode("utf8")
pattern = re.compile(r">(.+)人でBGM共有中<")
match = pattern.search(s)
if match!=None:
num_audience = int(match.groups()[0])
if num_audience > 1:
print("もう1人いる\n")
print("audience: %d\n" % (num_audience,))
else:
print("なんかパースエラー\n")
print("レスポンステキスト↓\n")
print(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment