Last active
May 25, 2018 13:20
-
-
Save PattyAppier/f0eba99af8ee56d213930472236a36a7 to your computer and use it in GitHub Desktop.
ExchangeRate_Python
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
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "Wish Luck is with you today!" | |
#if _name_ == "_main_": | |
#app.run() |
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
from typing import Dict, Any | |
import pandas | |
class Money(object): | |
def __init__(self, money_table, cash_buy, cash_sell, spot_buy, spot_sell): | |
self.money_table = money_table # self.fun = param name | |
self.cash_buy = cash_buy | |
self.cash_sell = cash_sell | |
self.spot_buy = spot_buy | |
self.spot_sell = spot_sell | |
def search_data(): | |
data = pandas.read_html("http://rate.bot.com.tw/xrt?Lang=zh-TW")[0] # attr | |
money_table = data.ix[:, 0:5] # [rows,columns] | |
money_table.columns = ["Currency", "Cash Buy", "Cash Sell", "Spot Buy", "Spot Sell"] | |
money_table["Currency"] = money_table["Currency"].str.extract("\((\w+)\)", expand= True) | |
money_dic = {} | |
for i in range(0, 19): | |
dollar = money_table.values[i] # i means key | |
money_dic[i] = Money(dollar[0], dollar[1], dollar[2], dollar[3], dollar[4]) | |
return (money_dic) | |
money_dic = Money.search_data() | |
for i in range(0, 19): | |
print(money_dic[i].money_table) | |
print(money_dic[i].cash_buy) | |
print(money_dic[i].cash_sell) | |
print(money_dic[i].spot_buy) | |
print(money_dic[i].spot_sell) | |
print(".........") |
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
Flask==1.0.2 | |
beautifulsoup4==4.6.0 | |
html5lib==1.0.1 | |
lxml==4.2.1 | |
pandas==0.23.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment