import os

import re

import time

import pymysql

import facebook

import requests

import configparser

import urllib.request

import pandas as pd

from PIL import Image

from bs4 import BeautifulSoup

from datetime import datetime

from google.colab import drive

 

...(중략)

 

try:

  conn = pymysql.connect(

      host=HOST,

      user=USER,

      password=PASSWORD,

      db=DATABASE,

      charset=CHARSET,

      port=int(PORT),

      cursorclass=pymysql.cursors.DictCursor)

  

  resp = requests.get(TRG_URI)

 

  soup = BeautifulSoup(resp.text, 'lxml')

 

  udate = scrappy(soup, 'udate')

  confirmator = scrappy(soup, 'confirmator')

  dead = scrappy(soup, 'dead')

  suspected = scrappy(soup, 'suspected')

  inspection = scrappy(soup, 'inspection')    

 

  print('udate: ', udate)

  print('confirmator: ', confirmator)

  print('dead: ', dead)

  print('suspected: ', suspected)

  print('inspection: ', inspection)

  

  cnt = exec_select(conn,udate)

  

  if cnt:

    print('overlap seq: ',cnt)

  else:

    print('does not overlap seq: ',cnt)

    exec_insert(conn,udate,confirmator,dead,suspected,inspection)

    send_facebook(udate,confirmator,dead,suspected,inspection)

    send_facebook2(udate,confirmator,dead,suspected,inspection)

    send_teams(udate,confirmator,dead,suspected,inspection)

 

  # send_facebook(udate,confirmator,dead,suspected,inspection)

  # send_facebook2(udate,confirmator,dead,suspected,inspection)

  # send_teams(udate,confirmator,dead,suspected,inspection)

 

except Exception as e:

  with open(ERR_URI+'error.log','a') as file:

    file.write('{} You got an error: {}\n'.format(datetime.today().strftime('%Y-%m-%d %H:%M:%S'),str(e)))

 

아래의 깃허브에 소스를 공유합니다.

 

https://github.com/gyunseul9/coronacolab

Posted by 앤비
,