rendered paste bodyimport urllib2
#get teamid and download corresponding alltid page
teamid = input('team id?: ')
print
print('working...')
print
print
tempfile = urllib2.urlopen('http://alltid.org/team/' + str(teamid) + '/teammatches/0/14/').read()
#find teamname
teamname = tempfile[tempfile.find('Match list for ')+15:tempfile.find(' | alltid hattrick')]
#cut to the beginning of tbody
tempfile = tempfile[tempfile.find('</thead>'):]
tempfile = tempfile[tempfile.find('</tr>')+3:]
#header
print 'current matches for: ' + teamname
print
print 'ROUND'.ljust(7) + 'DATE'.ljust(12) + 'AGAINST'.ljust(22) + \
'TACTIC (SKILL IN TACTIC) ARENA SCHEME ' + 'RESULT'.ljust(9) + 'ahtotal ahdef ahmid ahatt'
#do the job
newmatch = 0
breaknextround = 0
arena = 'home'
while 1:
templine = tempfile[:tempfile.find('</tr>')+3]
tempfile = tempfile[tempfile.find('</tr>')+3:]
if breaknextround == 1:
break
if tempfile.find('Head2Head') == -1:
breaknextround = 1
if (templine.find('<td colspan="13"></td>') == -1):
if (templine.find('Head2Head') == -1):
if templine.find(teamname) == -1:
templine = templine[templine.find('<td')+4:]
oppname = templine[templine.find('/">')+3:templine.find('</a>')]
templine = templine[templine.find('<td')+4:]
templine = templine[templine.find('<td')+4:]
templine = templine[templine.find('<td')+4:]
oppgoals = templine[templine.find('>')+1:templine.find('</td>')]
arena = 'home'
newmatch = 0
else:
templine = templine[templine.find('<td')+4:]
templine = templine[templine.find('<td')+4:]
formation = templine[templine.find('">')+2:templine.find('</td>')]
templine = templine[templine.find('<td')+4:]
tactic = templine[templine.find('">')+2:templine.find('</td>')]
templine = templine[templine.find('<td')+4:]
owngoals = templine[templine.find('">')+2:templine.find('</td>')]
templine = templine[templine.find('<td')+4:]
loddar = templine[templine.find('">')+2:templine.find('</td>')]
templine = templine[templine.find('<td')+5:]
ahtotal = templine[:templine.find('</td>')]
templine = templine[templine.find('<td')+5:]
ahdef = templine[:templine.find('</td>')]
templine = templine[templine.find('<td')+5:]
ahmid = templine[:templine.find('</td>')]
templine = templine[templine.find('<td')+4:]
ahatt = templine[templine.find('">')+2:templine.find('</td>')]
arena = 'away'
newmatch = 0
else:
roundrow = templine[templine.find('Round')-12:templine.find('Round')+13]
digits = roundrow[18:roundrow.find('</td>')]
if len(digits) == 1:
matchround = '0' + digits + ' '*5 + roundrow[:10]
else:
matchround = digits + ' '*5 + roundrow[:10]
newmatch += 1
else:
newmatch += 1
if newmatch == 1:
if owngoals > oppgoals:
winner = 'W'
elif owngoals == oppgoals:
winner = 'D'
else:
winner = 'L'
print matchround + ' '*2 + oppname.ljust(20)[:20] + ' '*2 + tactic.ljust(26)[:26] + ' '*2 + \
arena + ' '*3 + formation + ' '*2 + owngoals.rjust(2) + ':' + oppgoals.rjust(2) + ' ' + \
winner + ' '*2 + ahtotal.rjust(6) + ' '*3 + ahdef.rjust(5) + ' '*2 + ahmid.rjust(5) + \
' '*2 + ahatt.rjust(5)
print 'ROUND'.ljust(7) + 'DATE'.ljust(12) + 'AGAINST'.ljust(22) + \
'TACTIC (SKILL IN TACTIC) ARENA SCHEME ' + 'RESULT'.ljust(9) + 'ahtotal ahdef ahmid ahatt'