Guest User

Untitled

a guest
May 9th, 2020
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. import requests
  4. from bs4 import BeautifulSoup
  5. bot = commands.Bot(command_prefix='$')
  6. @bot.event
  7. async def on_ready():
  8.     print(bot.user.name)
  9.     print(bot.user.id)
  10. @bot.command()
  11. async def covid19(ctx):
  12.     article_href = []
  13.     r = requests.get("https://nidss.cdc.gov.tw/ch/NIDSS_DiseaseMap.aspx?dc=1&dt=5&disease=19CoV")
  14.     s = r.text[r.text.find('<span id="ctl00_NIDSSContentPlace_Table">'):].split('\n')[0]
  15.     soup = BeautifulSoup(s,"html.parser")
  16.     th = [i.find("th").text for i in soup.find_all("tr")[1:]]
  17.     td = [i.find("td").text for i in soup.find_all("tr")[1:-1]] + [soup.find_all("th")[-1].text]
  18.     output = ["{} {}".format(i,j) for i,j in zip(th,td)]
  19.     print('\n'.join(output))
  20.     await ctx.send('\n'.join(output))
  21.  
  22. bot.run('PASTE YOUR TOKEN HERE')
Advertisement
Add Comment
Please, Sign In to add comment