本文整理汇总了Python中bank.Bank类的典型用法代码示例。如果您正苦于以下问题:Python Bank类的具体用法?Python Bank怎么用?Python Bank使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bank类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetchBankList
def fetchBankList(self):
banks = [];
baseUrl = "http://www.nbcb.com.cn/xyk/thtghd/index%s.shtml";
for page in range(1, self.getPageRange()):
url = None;
if page == 1:
url = baseUrl % "";
else:
url = baseUrl % "_" + str(page);
soup = self.getSoup(url);
if not soup:
break;
for a in soup.find("div", class_="newslist").find_all("a", class_=""):
b = Bank();
b.url = "http://www.nbcb.com.cn" + a["href"].encode("utf-8");
title = soup_util.getStrings(a);
m = re.match(r"\[(.*)\]", title);
if m:
b.city = m.group(1);
b.title = re.sub(r"\[(.*)\]|【(.*)】", "", title);
banks.append(b);
return banks;
示例2: createBank
def createBank(number=0):
"""Saves a bank with the specified number of accounts.
Used during testing."""
bank = Bank()
for i in xrange(number):
bank.add(SavingsAccount("Name" + str(i), str(1000 + i), 100.00))
bank.save("bank.dat")
示例3: fetchBankList
def fetchBankList(self):
prefUrls = ["http://creditcard.hxb.com.cn/hotnews/index.jsp?cid=12347700871250001", "http://creditcard.hxb.com.cn/hotnews/index.jsp?cid=12347701281290003"];
banks = [];
for prefUrl in prefUrls:
for page in range(0, self.getPageRange()):
url = prefUrl + "&page_count=30&page_start=%d" % (page*5);
soup = self.getSoup(url);
if not self.isValidSoup(soup):
break;
lis = soup.find_all("div", id="rm_lcd");
for l in lis:
b = Bank();
a = l.find("a");
b.url = "http://creditcard.hxb.com.cn/hotnews/" + a["href"].encode("utf-8");
b.title = a["title"].encode("utf-8").strip();
h6 = l.find("h6").string;
if h6 != None:
m = re.match("\[.*至(.*)\]", h6.encode("utf-8"));
if m != None:
b.endDate = date_parser.parseDashLineStyle(m.group(1));
banks.append(b);
return banks;
示例4: test_checking_account
def test_checking_account():
bank = Bank()
checkingAccount = Account(CHECKING)
bill = Customer("Bill").openAccount(checkingAccount)
bank.addCustomer(bill)
checkingAccount.deposit(100.0)
assert_equals(bank.totalInterestPaid(), 0.1)
示例5: fetchBankList
def fetchBankList(self):
banks = [];
baseUrl = "http://creditcard.pingan.com/cms-tmplt/creditcard/searchPreferentialActivity.do?type=&city=shenzhen¤tPage=%d";
for page in range(1, self.getPageRange()):
url = baseUrl % page;
soup = self.getSoup(url);
if not soup:
break;
lis = soup.find_all("tr", class_="item");
if len(lis) == 0:
break;
for l in lis:
b = Bank();
a = l.find("a");
title = a["title"].encode("utf-8");
m = re.match(r"\[(.*)\]", title);
if m:
b.city = m.group(1);
b.title = re.sub(r"【.*】|\[.*\]", "", title);
b.url = "http://creditcard.pingan.com" + a["href"].encode("utf-8");
ds = l.contents[-2].string.encode("utf-8");
b.endDate = date_parser.parseDashLineStyle(ds);
banks.append(b);
return banks;
示例6: fetchBankList
def fetchBankList(self):
banks = []
baseUrl = "http://www.bankofshanghai.com/servlet/ServletGate?op=Forward&cur_page=MorePage&target=more&systemModule=1104&cid=110404&page=%d&menuId=&navigation=-%20%25D2%25F8%25D0%25D0%25BF%25A8%25D2%25B5%25CE%25F1%25B6%25AF%25CC%25AC"
for p in range(1, self.getPageRange()):
url = (
"http://www.bankofshanghai.com/servlet/ServletGate?op=Forward&cur_page=MorePage&target=more&systemModule=1104&cid=110404&page="
+ str(p)
+ "&menuId=&navigation=-%20%25D2%25F8%25D0%25D0%25BF%25A8%25D2%25B5%25CE%25F1%25B6%25AF%25CC%25AC"
)
soup = self.getSoup(url)
if not soup or self.isSoupEquals(soup, self.prevSoup):
break
self.prevSoup = soup
for td in soup.find_all("td", bgcolor="#F5F5F5", width="71%"):
b = Bank()
a = td.find("a")
if not a:
continue
b.url = "http://www.bankofshanghai.com/" + a["href"].encode("utf-8")
b.title = a["title"].encode("utf-8")
banks.append(b)
return banks
示例7: fetchBankList
def fetchBankList(self):
banks = [];
baseUrls = ["http://xyk.cebbank.com/home/activities/category/a_region_dd/list%d.htm","http://xyk.cebbank.com/home/activities/category/a_life_cycle/list%d.htm",];
print baseUrls;
for bu in baseUrls:
for page in range(1, self.getPageRange()):
##url = "http://xyk.cebbank.com/home/activities/category/a_life_cycle/list%d.htm" % page;
url = bu % page;
soup = self.getSoup(url);
if not self.isValidSoup(soup):
break;
lis = soup.find("ul", class_="th_list_ul").find_all("div", class_="floatleft");
for l in lis:
b = Bank();
a = l.find("a");
b.url = "http://xyk.cebbank.com" + a["href"].encode("utf-8");
title = a.string.encode("utf-8").strip();
m = re.match(r"(.*?)((.*))", title);
if m:
b.title = m.group(1);
b.city = m.group(2);
else:
b.title = title;
banks.append(b);
return banks;
示例8: test_get_account_balance
def test_get_account_balance(self):
bank = Bank()
account1 = Account('001', 50)
bank.add_account(account1)
self.assertEqual(bank.get_account_balance('001'), 50)
示例9: test_add_account
def test_add_account(self):
bank = Bank()
account_1 = Account(001, 50)
account_2 = Account(002, 100)
bank.add_account(account_1)
bank.add_account(account_2)
self.assertEqual(len(bank.accounts), 2)
示例10: main
def main(fileName = None):
"""Creates the bank with the optional file name,
wraps the window around it, and opens the window.
Saves the bank when the window closes."""
bank = Bank(fileName)
print(bank)
manager = BankManager(bank)
manager.mainloop()
bank.save()
示例11: test_deposit
def test_deposit(self):
bank = Bank()
account_1 = Account(001, 50)
bank.add_account(account_1)
self.assertEqual(bank.deposit(001, 50), 100)
self.assertEqual(bank.deposit(002, 50), 'Account does not exist')
示例12: test_add_account
def test_add_account(self):
bank = Bank()
account1 = Account('001', 20)
account2 = Account('002', 80)
bank.add_account(account1)
bank.add_account(account2)
self.assertEqual(len(bank.accounts), 2)
示例13: main
def main():
"""Instantiate a bank and use it in an ATM."""
bank = Bank("bank.dat")
print "The bank has been loaded"
atm = ATM(bank)
print "Running the GUI"
atm.mainloop()
bank.save()
print "The bank has been updated"
示例14: parseInner
def parseInner(self, url):
banks = [];
soup = self.getSoup(url);
for a in soup.find("table", class_="ke-zeroborder").find_all("a"):
b = Bank();
b.url = a["href"].encode("utf-8");
title = a.string.encode("utf-8");
b.title = self.removeCity(title);
banks.append(b);
return banks;
示例15: fetchBankList
def fetchBankList(self):
banks = [];
soup = self.getSoup("http://creditcard.gzcb.com.cn/Activities3.html", encoding="gbk");
if not soup:
return banks;
for a in soup.find("div", class_="active_C").find("ul").find_all("a"):
b = Bank();
b.url = "http://creditcard.gzcb.com.cn/" + a["href"].encode("utf-8");
b.title = a.string.encode("utf-8");
banks.append(b);
return banks;