Posted by 세상을 살아가는 사람
,

Posted by 세상을 살아가는 사람
,

운동을 해야지

Posted by 세상을 살아가는 사람
,

29일 아침, 콘도 주변을 산책하며, 골프 코스에 있는 골프공과 밤을 주웠다.

Posted by 세상을 살아가는 사람
,

위례에 있는 황토길을 아내와 같이 걸었다.

Posted by 세상을 살아가는 사람
,
import pymysql
import requests
from bs4 import BeautifulSoup
import schedule

dbURL = "127.0.0.1"
dbPort = 3306
dbUser = 'study'
dbPass = 'study'

conn = pymysql.connect(
    host=dbURL, port=dbPort, user=dbUser, passwd=dbPass, db='jspdb',
    charset='utf8', use_unicode=True
)

insert_weather = "insert into jspdb.weather (city,tmef,wf,tmn,tmx) values (%s, %s, %s, %s, %s)"
select_last_date = "select tmef from jspdb.weather order by tmef desc limit 1"

def job():
    req = requests.get("http://www.weather.go.kr/weather/forecast/mid-term-rss3.jsp?stnId=108")
    html = req.text
    soup = BeautifulSoup(html, 'lxml')
    
    cur = conn.cursor()
    cur.execute(select_last_date)
    last_date = cur.fetchone()
    conn.commit()

    weather = {}
    # city, tmef, wf, tmn, tmx
    for i in soup.find_all('location'):
        weather[i.find('city').text] = []
        for j in i.find_all('data'):
            temp = []
            if(j.find('tmef').text > last_date):
                temp.append(j.find('tmef').text)
                temp.append(j.find('wf').text)
                temp.append(j.find('tmn').text)
                temp.append(j.find('tmx').text)
                weather[i.find('city').string].append(temp)
    
    for i in weather:
        for j in weather[i]:
            cur = conn.cursor()
            cur.execute(insert_weather,(i,j[0],j[1],j[2],j[3]))
            conn.commit()

schedule.every().day.at("06:00").do(job)

while True:
    schedule.run_pending()
Posted by 세상을 살아가는 사람
,

정규표현식에 대한 연습을 해볼 수 있는 사이트를 소개한다.

https://regexone.com/lesson/letters_and_digits? 

 

RegexOne - Learn Regular Expressions - Lesson 1½: The 123s

Characters include normal letters, but digits as well. In fact, numbers 0-9 are also just characters and if you look at an ASCII table, they are listed sequentially. Over the various lessons, you will be introduced to a number of special metacharacters use

regexone.com

자바스크립트나 자바에서 많이 사용되지만, 난이도가 있어 어려움이 있는데,

흥미롭게 연습할 수 있는 사이트가 있어 공유해 본다.

Posted by 세상을 살아가는 사람
,
Posted by 세상을 살아가는 사람
,
Posted by 세상을 살아가는 사람
,

몇 년만에 방문한 것 같다.
방문자가 적어 잘 이용하지 않았었다가 다시 사용을 더 적극적으로 해보려고 한다.

Posted by 세상을 살아가는 사람
,