-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet_Bank.py
More file actions
26 lines (22 loc) · 806 Bytes
/
Get_Bank.py
File metadata and controls
26 lines (22 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
class Foreign_Exchange_Rate:
def __init__(self):
url = 'http://rate.bot.com.tw/xrt?Lang=zh-TW'
html = requests.get(url).text
self.soup = BeautifulSoup(html, 'html.parser')
self.__Get_All()
def main(self):
time = str(self.soup.select('.time')).split('>')[1].split('<')[0]
print time
print self.all
def __Get_All(self):
rows=self.soup.find('table',{'class','table table-striped table-bordered table-condensed table-hover'}).tbody.find_all('tr')
temp=[]
all=[]
for row in rows:
temp.append([s for s in row.stripped_strings])
for i in temp:
all.append([i[0],i[2],i[3],i[4],i[5]])
self.all=all