-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfood.py
36 lines (23 loc) · 1.02 KB
/
food.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests
from pyquery import PyQuery
from telegram import ParseMode
from telegram.ext import CommandHandler
meal = ['☀*조식*☀', '🕐*중식*🕐', '🌙*석식*🌙']
def food(update, context):
url = 'https://ksa.hs.kr/Home/CafeteriaMenu/72'
r = requests.get(url)
html = PyQuery(r.text)
table = html(".meal ul")
morning = meal[0] + '\n'
for li in table.eq(0).children().items():
morning += li.text() + '\n'
lunch = meal[1] + '\n'
for li in table.eq(1).children().items():
lunch += li.text() + '\n'
dinner = meal[2] + '\n'
for li in table.eq(2).children().items():
dinner += li.text() + '\n'
context.bot.send_message(chat_id=update.message.chat_id, text=morning, parse_mode=ParseMode.MARKDOWN)
context.bot.send_message(chat_id=update.message.chat_id, text=lunch, parse_mode=ParseMode.MARKDOWN)
context.bot.send_message(chat_id=update.message.chat_id, text=dinner, parse_mode=ParseMode.MARKDOWN)
food_handler = CommandHandler('food', food)