requests 의 결과를 받아서 엑셀로 저장하기 인데...

조금 수정하여 사용하면 원하는 결과를 만들기 쉽다.

 

import requests
import pandas as pd

data = {
    'method' : [],
    'url' : [],
    'result' : [],
}
df = pd.DataFrame(data)

r = requests.get('https://naver.com')
append_data = {'method': r.request.method, "url" : r.url, "result" : r.text}
df2 = df.append(append_data, ignore_index=True)
df2.to_excel('out_test.xlsx')

 

엑셀 자료를 읽어 DB 에 저장하는 경우에 굉장히 유용하다.

insert into 구문 없이 이렇게 넣는게 더 편하다.

import pandas as pd
import psycopg2
import sqlalchemy
from sqlalchemy import create_engine


engine = create_engine("postgresql://userid:password@dbip:dbport/dbname")

df = pd.read_excel("C:\\Users\\user\\testDB.xlsx", header = 0)
print (df)

df.to_sql(name = 'emo_dict',
          con = engine,
          schema = 'public',
          if_exists = 'append',
          index = False
          )

print ("=================end")

 

du -sh *

 

Centos6 yum update 오류

yum update
Loaded plugins: fastestmirror, security
Setting up Update Process
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

 

아래 명령어 입력후 yum update 시 정상작동 한다

echo https://vault.centos.org/6.10/os/x86_64/ > /var/cache/yum/x86_64/6/base/mirrorlist.txt
echo http://vault.centos.org/6.10/extras/x86_64/ > /var/cache/yum/x86_64/6/extras/mirrorlist.txt
echo http://vault.centos.org/6.10/updates/x86_64/ > /var/cache/yum/x86_64/6/updates/mirrorlist.txt

yum -y update

 

수정

crontab -e

 

 

45 22 * * *                         22시45분에 실행
28 03 * * *                         03시28분에 실행
0 17 * * *                          17시00분에 실행
0 17 * * 1                          매주 월요일 17시00분에 실행
0,10 17 * * 0,2,3                  매주 일, 화, 수요일 17시00 분과 17시10분에 실행
0-10 17 1 * *                      매달 1일 17시00분부터17시10분까지 1분 단위로 실행
0 0 1,15 * 1                        매달 1일과 15일 그리고 월요일 24시00분에 실행
42 4 1 * *                           매달 1일 4시42분에 실행
0 21 * * 1-6                        월요일 부터토요일까지 21시00분에 실행
0,10,20,30,40,50 * * * *         10분 간격으로 실행
*/10 * * * *                         10분 간격으로 실행
*/5 * * * *                           5분 간격으로 실행
* 1 * * *                             1시00분 부터 1시59분 까지 1분 간격으로 실행
0 1 * * *                             1시00분에 실행
0 */1 * * *                          매시간 0분에 실행(1시간 간격으로 실행)
0 * * * *                             매시간 0분에 실행(1시간 간격으로 실행)
5 2-5 * * *                         2시 5분, 3시 5분, 4시 5분, 5시 5분에 실행
2 8-20/3 * * *                     8시 2분, 11시 2분, 14시 2분, 17시 2분, 20시 2분에 실행
30 5 1,15 * *                      매달 1일과 15일 5시30분에 실행

startTomcat.sh 라는 쉘파일을 아래와 같이 만들고

cat startTomcat.sh
#!/bin/bash
while [ 1 ]
   do
        pid=`ps -ef | grep "tomcat7.0.14" | grep -v 'grep' | awk '{print $2}'`
        if [ -z $pid ]; then
         /usr/local/tomcat7.0.14/bin/startup.sh
        fi
   done

 

startTomcat.sh &

'리눅스' 카테고리의 다른 글

Centos 6.9 yum update error  (0) 2021.05.24
리눅스 crontab 사용법  (0) 2021.04.30
시작 프로그램 등록  (0) 2021.04.30
리눅스의 logrotate를 이용한 tomcat 로그파일 롤링방법  (0) 2021.04.30
find 명령어  (0) 2021.04.30

centos 에서 mysqlclient 설치가 안될때...

 

yum install MariaDB-shared MariaDB-shared-debuginfo

 

이거 넣어서 다 해결됐다.

 

rc.local 파일에 시작할 프로그램을 등록하면 된다.

vi  /etc/rc.local

 

 

그룹으로 묶고 싶다면 하나의 쉘 스크립트를 만들고, 그 쉘스크립트를 등록하는 방법이 좋다.

 

#추가

/root/startup/mount.sh

+ Recent posts