Advertisement
Guest User

Untitled

a guest
Jul 30th, 2010
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.83 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # coding=utf-8
  3. import re
  4. import twitter
  5. import urllib
  6.  
  7. # настройки
  8. my_mark = 214 # ваш балл
  9. twitter_login = 'ha-ha' # логин в твиттере
  10. twitter_password = 'ha-ha' # пасс там же
  11.  
  12. # main
  13. params = urllib.urlencode({'dep': '8', 'form': 'О', 'listtype': '2', 'spec': '1', 'submit': 'Показать'})
  14. page = urllib.urlopen('http://priem.mai.ru/clists/', params).read().replace('\n', '').replace('\r', '')
  15. matches = re.compile('<tr><td>([0-9]+)</td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td><td>(.+?)</td></tr>').findall(page)
  16.  
  17. # Счётчики
  18. counter_better = 0
  19. counter_worse = 0
  20. counter_with_hostel = 0
  21.  
  22. # Проходные баллы
  23. matk_with_hostel = 300
  24. mark_without_hostel = 300
  25.  
  26. # Считаем
  27. for i in range(len(matches)):
  28.     match = matches[i]
  29.     if match[5] == 'Без экзаменов':
  30.         mark = 300
  31.     elif match[5] == 'Вне конкурса':
  32.         mark = 300
  33.     else:
  34.         mark = int(match[4][0:3])
  35.        
  36.     if match[6] == 'Подлинник':
  37.         if match[9] == 'Не согласен':
  38.             counter_with_hostel += 1
  39.            
  40.             if counter_with_hostel <= 20:
  41.                 mark_with_hostel = mark
  42.         else:
  43.             if mark > my_mark:
  44.                 counter_better += 1
  45.             else:
  46.                 counter_worse += 1
  47.                
  48.             if (counter_better + counter_worse) <= 91:
  49.                 mark_without_hostel = mark
  50.  
  51. # Пишем в твиттер
  52. counter_without_hostel = counter_better + counter_worse
  53. counter_all = counter_with_hostel + counter_without_hostel 
  54. counter_worse -= 1 # Вычитаем себя самого    
  55. msg = ('MAI-8: {0}/{1}/{2}/91 ; {3}/111 ; {4}/{5}').format(counter_better, counter_worse, counter_without_hostel, counter_all, mark_without_hostel, mark_with_hostel)
  56. twitter.Api(twitter_login, twitter_password).PostUpdate(msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement