Skip to content

Instantly share code, notes, and snippets.

@songmw90
Created August 17, 2015 01:42
Show Gist options
  • Select an option

  • Save songmw90/4e169d31044d2b2bd70e to your computer and use it in GitHub Desktop.

Select an option

Save songmw90/4e169d31044d2b2bd70e to your computer and use it in GitHub Desktop.
Auto game record requester (op.gg)
#!/usr/bin/env python
# -*- coding: utf8 -*-
import urllib
import urllib2
import re,time
players = []
turn = -1
print "####################################################"
print "# OP.GG Auto Record Requester. made by Ghast(KR) #"
print "####################################################"
while (1):
if ( turn >= len(players)-1 ):
turn = 0
else:
turn = turn + 1
try:
data = 'userName={}&force=true'.format(players[turn])
headers = {'Host': 'www.op.gg',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0',
'Accept': '*/*',
'Accept-Language': 'ko,en-US;q=0.7,en;q=0.3',
'Accept-Encoding': 'utf-8',
'X-Requested-With': 'XMLHttpRequest',
'Content-Length': len(data),
'Connection': 'keep-alive',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
}
req = urllib2.Request('http://www.op.gg/summoner/ajax/spectator/', data, headers)
response = urllib2.urlopen(req)
the_page = response.read()
isAlreadyRecord = re.findall("녹화중인 게임",the_page)
except:
turn = turn - 1;
if not isAlreadyRecord:
try:
gameID = re.findall("\/observer/id=(.*?)\"",the_page)[0]
try:
req = urllib2.Request('http://www.op.gg/summoner/ajax/requestRecording.json/gameId={}'.format(gameID))
response = urllib2.urlopen(req)
print "{}'s game record request has been sent.".format(players[turn])
except Exception,err:
pass
except Exception,err:
pass
time.sleep(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment