pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Python paste-bin - collaborative debugging tool View Help


Posted by eorg on Fri 12th Jan 07:42
download | new post

  1. #opponent strength at glance by eorg
  2.  
  3. #as scanning hattrick is forbidden this script scans alltid.org and outputs some nice statistics
  4.  
  5. import urllib2
  6.  
  7. #get teamid and download corresponding alltid page
  8. teamid = input('team id?: ')
  9. leagueseason = input('season?: ')
  10. print
  11. print('working...')
  12. print
  13. print
  14. tempfile = urllib2.urlopen('http://alltid.org/team/' + str(teamid) + '/teammatches/0/' + \
  15.                            str(leagueseason) + '/').read()
  16.  
  17. #find teamname
  18. teamname = tempfile[tempfile.find('Match list for ')+15:tempfile.find(' | alltid hattrick')]
  19.  
  20. #cut to the beginning of tbody
  21. tempfile = tempfile[tempfile.find('</thead>'):]
  22. tempfile = tempfile[tempfile.find('</tr>')+3:]
  23.  
  24. #header
  25. print 'current matches for: ' + teamname
  26. print
  27. print 'ROUND'.ljust(7) + 'DATE'.ljust(12) + 'AGAINST'.ljust(22) + \
  28.       'TACTIC (SKILL IN TACTIC)    ARENA  SCHEME  ' + 'RESULT'.ljust(9) + 'ahtotal  ahdef  ahmid  ahatt'
  29.  
  30. #do the job
  31. newmatch = 0
  32. breaknextround = 0
  33. arena = 'home'
  34. while 1:
  35.     templine = tempfile[:tempfile.find('</tr>')+3]
  36.     tempfile = tempfile[tempfile.find('</tr>')+3:]
  37.     if breaknextround == 1:
  38.         break
  39.     if tempfile.find('Head2Head') == -1:
  40.         breaknextround = 1
  41.     if (templine.find('<td colspan="13"></td>') == -1):
  42.         if (templine.find('Head2Head') == -1):
  43.             if templine.find(teamname) == -1:
  44.                 templine = templine[templine.find('<td')+4:]
  45.                 oppname = templine[templine.find('/">')+3:templine.find('</a>')]
  46.                 templine = templine[templine.find('<td')+4:]
  47.                 templine = templine[templine.find('<td')+4:]
  48.                 templine = templine[templine.find('<td')+4:]
  49.                 oppgoals = templine[templine.find('>')+1:templine.find('</td>')]
  50.                 arena = 'home'
  51.                 newmatch = 0
  52.             else:
  53.                 templine = templine[templine.find('<td')+4:]
  54.                 templine = templine[templine.find('<td')+4:]
  55.                 formation = templine[templine.find('">')+2:templine.find('</td>')]
  56.                 templine = templine[templine.find('<td')+4:]
  57.                 tactic = templine[templine.find('">')+2:templine.find('</td>')]
  58.                 templine = templine[templine.find('<td')+4:]
  59.                 owngoals = templine[templine.find('">')+2:templine.find('</td>')]
  60.                 templine = templine[templine.find('<td')+4:]
  61.                 loddar = templine[templine.find('">')+2:templine.find('</td>')]
  62.                 templine = templine[templine.find('<td')+5:]
  63.                 ahtotal = templine[:templine.find('</td>')]
  64.                 templine = templine[templine.find('<td')+5:]
  65.                 ahdef = templine[:templine.find('</td>')]
  66.                 templine = templine[templine.find('<td')+5:]
  67.                 ahmid = templine[:templine.find('</td>')]
  68.                 templine = templine[templine.find('<td')+4:]
  69.                 ahatt = templine[templine.find('">')+2:templine.find('</td>')]
  70.                 arena = 'away'
  71.                 newmatch = 0
  72.         else:
  73.             roundrow = templine[templine.find('Round')-12:templine.find('Round')+13]
  74.             digits = roundrow[18:roundrow.find('</td>')]
  75.             if len(digits) == 1:
  76.                 matchround = '0' + digits + ' '*5 + roundrow[:10]
  77.             else:
  78.                 matchround = digits + ' '*5 + roundrow[:10]
  79.             newmatch += 1
  80.     else:
  81.         newmatch += 1
  82.     if newmatch == 1:
  83.         if owngoals > oppgoals:
  84.             winner = 'W'
  85.         elif owngoals == oppgoals:
  86.             winner = 'D'
  87.         else:
  88.             winner = 'L'
  89.         print matchround + ' '*2 + oppname.ljust(20)[:20] + ' '*2 + tactic.ljust(26)[:26] + ' '*2 + \
  90.               arena + ' '*3 + formation + ' '*2 + owngoals.rjust(2) + ':' + oppgoals.rjust(2) + ' ' + \
  91.               winner + ' '*2 + ahtotal.rjust(6) + ' '*3 + ahdef.rjust(5)  + ' '*2 + ahmid.rjust(5) + \
  92.               ' '*2 + ahatt.rjust(5)
  93. print 'ROUND'.ljust(7) + 'DATE'.ljust(12) + 'AGAINST'.ljust(22) + \
  94.       'TACTIC (SKILL IN TACTIC)    ARENA  SCHEME  ' + 'RESULT'.ljust(9) + 'ahtotal  ahdef  ahmid  ahatt'

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings