Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from vk_api.longpoll import VkLongPoll, VkEventType
- import vk_api
- import requests
- from lxml import html
- print('Математика - 1')
- print('Информатика - 2') # вывод в одном сообщении через новый абзац
- login, password = "+79995640123","T8y9l5e3r"
- token = "a238249ac1f75e1b9db6bdd434b69c690247f4011284e37d173fe6cccee0ee0fa15e30430223411b2f558"
- vk_session = vk_api.VkApi(token=token)
- session_api = vk_session.get_api()
- longpoll = VkLongPoll(vk_session)
- while True:
- for event in longpoll.listen():
- if event.type == VkEventType.MESSAGE_NEW:
- men = int()
- real = int()
- response = str(event.text.lower())
- if event.from_user :
- if response == "help":
- vk_session.method('messages.send',{'user_id': event.user_id, 'message': 'ВВедите предмет и тд, заебал ты, если честно!', 'random_id': 0})
- if event.from_user:
- if response == "math":
- subject = 1
- if event.from_user:
- if men == 1:
- ex = 1
- if event.from_user:
- if men == 1:
- count = 1
- task_p = ''
- k = 0
- subj = {
- '1': 'math', # проверить на всех заданиях
- '2': 'inf',
- 'Русский': 'rus' # не готов
- }
- params = {
- ('prob' + ex): count,
- 'public': False
- }
- inv = {
- '\xad': '',
- '\xa0': ''
- }
- url = 'https://' + subj[subject] + 'ege.sdamgia.ru'
- session = requests.session()
- r = session.post(url + '/test?a=generate', params)
- tree = html.fromstring(r.text)
- choice = tree.xpath('//div[@class = "new_header"]/b/text()')
- choice = choice[0]
- choice = choice[10::]
- prob = tree.xpath('//div[@class = "prob_maindiv"]')
- for i in prob:
- pro = prob[k].attrib['id']
- pro = pro[7::]
- k += 1
- params = {
- 'a': 'check',
- ('answer_' + str(k) + '_' + str(pro)): '',
- 'is_cr': 1,
- 'stat_id': 0,
- 'test_id': choice,
- 'timer': 1
- }
- r = session.post(url + '/test', params)
- tree = html.fromstring(r.text)
- t_answ = tree.xpath('//td[5]/text()')
- task = tree.xpath('//div[@class="pbody"][1]/p/text()')
- try:
- img = tree.xpath('//p/img/@src')[0]
- img = url + img
- except Exception:
- img = ''
- for i in task:
- task_p += i
- for i in inv:
- n = task_p.count(i)
- task_p = task_p.replace(i, '', n)
- print(task_p) # Вывод задания
- print(img)
- answ = input('Введите ответ: ')
- if t_answ[0] == answ:
- print('Верно, ответ: ', answ)
- else:
- print('Неверно')
- elif response == "пока":
- vk_session.method('messages.send', {'user_id': event.user_id, 'message': 'Пока, друг!', 'random_id': 0})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement