Toggle navigation
Toggle navigation
This project
Loading...
Sign in
wlstp8473
/
telegram_Messenger_Chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
wlstp8473
2021-06-08 13:25:28 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2521f10da903ebfba4f018faeda9cf7be3b4c3bd
2521f10d
1 parent
2487e74d
python json파일 생성 코드
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
line_chatbot_code/covid_respond/covid_crawling.py
line_chatbot_code/covid_respond/covid_crawling.py
View file @
2521f10
# -*- 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
resul
t
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
%9
C
%
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
)
...
...
Please
register
or
login
to post a comment