Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # coding=utf-8
- import re
- import twitter
- import urllib
- # настройки
- my_mark = 214 # ваш балл
- twitter_login = 'ha-ha' # логин в твиттере
- twitter_password = 'ha-ha' # пасс там же
- # main
- params = urllib.urlencode({'dep': '8', 'form': 'О', 'listtype': '2', 'spec': '1', 'submit': 'Показать'})
- page = urllib.urlopen('http://priem.mai.ru/clists/', params).read().replace('\n', '').replace('\r', '')
- 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)
- # Счётчики
- counter_better = 0
- counter_worse = 0
- counter_with_hostel = 0
- # Проходные баллы
- matk_with_hostel = 300
- mark_without_hostel = 300
- # Считаем
- for i in range(len(matches)):
- match = matches[i]
- if match[5] == 'Без экзаменов':
- mark = 300
- elif match[5] == 'Вне конкурса':
- mark = 300
- else:
- mark = int(match[4][0:3])
- if match[6] == 'Подлинник':
- if match[9] == 'Не согласен':
- counter_with_hostel += 1
- if counter_with_hostel <= 20:
- mark_with_hostel = mark
- else:
- if mark > my_mark:
- counter_better += 1
- else:
- counter_worse += 1
- if (counter_better + counter_worse) <= 91:
- mark_without_hostel = mark
- # Пишем в твиттер
- counter_without_hostel = counter_better + counter_worse
- counter_all = counter_with_hostel + counter_without_hostel
- counter_worse -= 1 # Вычитаем себя самого
- 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)
- twitter.Api(twitter_login, twitter_password).PostUpdate(msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement