Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- import requests
- from bs4 import BeautifulSoup
- bot = commands.Bot(command_prefix='$')
- @bot.event
- async def on_ready():
- print(bot.user.name)
- print(bot.user.id)
- @bot.command()
- async def covid19(ctx):
- article_href = []
- r = requests.get("https://nidss.cdc.gov.tw/ch/NIDSS_DiseaseMap.aspx?dc=1&dt=5&disease=19CoV")
- s = r.text[r.text.find('<span id="ctl00_NIDSSContentPlace_Table">'):].split('\n')[0]
- soup = BeautifulSoup(s,"html.parser")
- th = [i.find("th").text for i in soup.find_all("tr")[1:]]
- td = [i.find("td").text for i in soup.find_all("tr")[1:-1]] + [soup.find_all("th")[-1].text]
- output = ["{} {}".format(i,j) for i,j in zip(th,td)]
- print('\n'.join(output))
- await ctx.send('\n'.join(output))
- bot.run('PASTE YOUR TOKEN HERE')
Advertisement
Add Comment
Please, Sign In to add comment