import 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(''):] tempfile = tempfile[tempfile.find('')+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('')+3] tempfile = tempfile[tempfile.find('')+3:] if breaknextround == 1: break if tempfile.find('Head2Head') == -1: breaknextround = 1 if (templine.find('') == -1): if (templine.find('Head2Head') == -1): if templine.find(teamname) == -1: templine = templine[templine.find('')+3:templine.find('')] templine = templine[templine.find('')+1:templine.find('')] arena = 'home' newmatch = 0 else: templine = templine[templine.find('')+2:templine.find('')] templine = templine[templine.find('')+2:templine.find('')] templine = templine[templine.find('')+2:templine.find('')] templine = templine[templine.find('')+2:templine.find('')] templine = templine[templine.find('')] templine = templine[templine.find('')] templine = templine[templine.find('')] templine = templine[templine.find('')+2:templine.find('')] arena = 'away' newmatch = 0 else: roundrow = templine[templine.find('Round')-12:templine.find('Round')+13] digits = roundrow[18:roundrow.find('')] 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'