Created
June 10, 2017 02:29
-
-
Save KimMyungSam/17fd80a05bd56d0dad34be2dfecb62af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\n", | |
"BBB-\n", | |
"3.80\n", | |
"4.46\n", | |
"5.12\n", | |
"5.58\n", | |
"6.32\n", | |
"7.11\n", | |
"8.28\n", | |
"8.60\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"import requests\n", | |
"from bs4 import BeautifulSoup\n", | |
"from datetime import datetime, timedelta\n", | |
"\n", | |
"today = datetime.today()\n", | |
"yesterday = today - timedelta(1)\n", | |
"yesterday = yesterday.strftime(\"%Y%m%d\")\n", | |
"\n", | |
"url = 'http://www.kisrating.com/ratings/statics_interest.asp?gubun=1&sdate='+yesterday\n", | |
"html = requests.get(url).text\n", | |
"soup = BeautifulSoup(html,'lxml')\n", | |
"tr_list = soup.find_all('tr')\n", | |
"bbb_ = tr_list[12].get_text()\n", | |
"print (bbb_)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[ 0 1\n", | |
"0 기준일 NaN, 구분 3월 6월 9월 1년 1년6월 2년 3년 5년\n", | |
"0 국고채 1.26 1.31 1.38 1.42 1.49 1.53 1.63 1.85\n", | |
"1 AAA 1.39 1.43 1.51 1.61 1.66 1.77 1.93 2.16\n", | |
"2 AA+ 1.43 1.46 1.52 1.62 1.68 1.79 1.98 2.28\n", | |
"3 AA 1.48 1.51 1.58 1.67 1.72 1.85 2.03 2.37\n", | |
"4 AA- 1.53 1.56 1.62 1.72 1.77 1.89 2.08 2.47\n", | |
"5 A+ 1.85 1.92 2.02 2.18 2.24 2.46 2.75 3.13\n", | |
"6 A 2.00 2.06 2.17 2.34 2.40 2.61 2.99 3.53\n", | |
"7 A- 2.22 2.30 2.41 2.60 2.66 2.89 3.36 4.06\n", | |
"8 BBB+ 2.75 3.17 3.61 3.93 4.40 5.02 5.87 6.13\n", | |
"9 BBB 3.13 3.67 4.19 4.60 5.21 5.96 6.92 7.18\n", | |
"10 BBB- 3.80 4.46 5.12 5.58 6.32 7.11 8.28 8.60\n", | |
"11 BB+ 5.25 6.03 6.72 7.29 8.02 8.84 10.22 10.89\n", | |
"12 BB 5.96 6.77 7.49 8.08 8.85 9.71 11.14 11.88\n", | |
"13 BB- 6.50 7.31 8.04 8.64 9.42 10.28 11.73 12.48\n", | |
"14 B 10.28 11.28 12.17 12.90 13.90 14.95 16.69 17.86]\n" | |
] | |
} | |
], | |
"source": [ | |
"import requests\n", | |
"import pandas as pd\n", | |
"from bs4 import BeautifulSoup\n", | |
"from datetime import datetime, timedelta\n", | |
"\n", | |
"today = datetime.today()\n", | |
"yesterday = today - timedelta(1)\n", | |
"yesterday = yesterday.strftime(\"%Y%m%d\")\n", | |
"\n", | |
"url = 'http://www.kisrating.com/ratings/statics_interest.asp?gubun=1&sdate='+yesterday\n", | |
"html = requests.get(url).text\n", | |
"bbb_ = pd.read_html(html)\n", | |
"print (bbb_)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment