wlstp8473

python json파일 생성 코드

# -*- coding: utf-8 -*-
import json
import telegram
from telegram.ext import Updater
from telegram.ext import MessageHandler, Filters
......@@ -16,7 +19,7 @@ def covid_num_crawling():
soup = BeautifulSoup(code, "html.parser")
info_num = soup.select("div.status_today em")
result = int(info_num[0].string) + int(info_num[1].string)
return result
return resul
def covid_news_crawling():
code = req.urlopen("https://search.naver.com/search.naver?where=news&sm=tab_jum&query=%EC%BD%94%EB%A1%9C%EB%82%98")
......@@ -32,6 +35,15 @@ def covid_news_crawling():
return output_result
def toJson(mnet_dict):
with open('mnet_chart.json', 'w', encoding='utf-8') as file :
json.dump(mnet_dict, file, ensure_ascii=False, indent='\t')
#텔레그램 관련 코드
token = "1721885449:AAHDGMbjSJfhXxML6nfSCpfiU7SghpL_vOE"
id = "1657858421"
......@@ -77,4 +89,3 @@ def handler(update, context):
echo_handler = MessageHandler(Filters.text, handler)
dispatcher.add_handler(echo_handler)
......