2013-07-24 53 views
2

我想使用一个python web scrapping库,它将登录到我的银行,类似于下面的代码并获得账户余额。 下面的代码使用分裂,然而它需要安装的Web客户端。问题是我无法在beaglebone板命令行上安装Web客户端。使用python scapping库推荐刮去银行网站

这里是代码,请指教,如果有另一种选择

from splinter import Browser 

# Define the username and password 
username2 = 'xxxxxxxxxx' 
password2 = 'xxxxxxxxx' 

# Choose the browser (default is Firefox) 
browser2 = Browser(user_agent="Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en)") 

# Fill in the url 
browser2.visit('https://www.my.commbank.com.au/netbank/Logon/Logon.aspx') 

# Find the username form and fill it with the defined username 
browser2.find_by_id('txtMyClientNumber_field').first.find_by_tag('input').fill(username2) 

# Find the password form and fill it with the defined password 
browser2.find_by_id('txtMyPassword_field').first.find_by_tag('input').fill(password2) 

# Find the submit button and click 
browser2.find_by_id('btnLogon').first.click() 

# Print the current url 
print browser2.url 

# Print the current browser title 
print browser2.title 

# Print the current html source code 
print browser2.html 

下面是从银行网站的源代码

<div class="ft"> 
<div class="row"> 
<div class="LabelWrapper LabelTextAlignNotSet align_notset"> 
<label for="txtMyClientNumber_field" id="txtMyClientNumber_label"><span class="MainLabel ">Client number</span></label> 
</div><div class="FieldElement "> 
<input name="txtMyClientNumber$field" value="XXXX5050" maxlength="8" id="txtMyClientNumber_field" class="text textbox field" data-maxlength="8" type="text"> 
</div> 
</div> 

<div class="row"> 
<div class="LabelWrapper LabelTextAlignNotSet align_notset"> 
<label for="txtMyPassword_field" id="txtMyPassword_label"><span class="MainLabel ">Password</span></label> 
</div><div class="FieldElement "> 
<input name="txtMyPassword$field" maxlength="16" id="txtMyPassword_field" class="text textbox field" data-maxlength="16" type="password"> 
</div> 
</div> 

<div class="row"> 
<div class="FieldElement FieldElementNoLabel"> 
<span class="checkbox field checkbox_classic"><input id="chkRemember_field" name="chkRemember$field" checked="checked" class="checkbox" type="checkbox"><label for="chkRemember_field">Remember client number</label></span> 
</div> 
</div> 

<input value="a%3D1374655030258%3Bm%3D-660*-600%3Bf%3D2560k1440k24%3Bz%3D74%3Bc%3D4%3Bb%3DZnpVagry%3By%3Dra-HF%3Bs%3D1%3Bw%3D11%2Cuggcf%253N//pon.qrzqrk.arg/rirag%253Sq_afvq%253Q0%2526q_yq%253Q_gf%25253Q1374655029179%2526p_cntrAnzr%253Qao%25253Nybtba%25253Nybtba%2526p_punaary%253Qao%25253Nybtba%25253Nybtba%2526p_cebc1%253Qao%25253Nybtba%2526p_cebc2%253Qao%2526p_cebc7%253Q6%25253N30CZ%2526p_rIne7%253Q6%25253N30CZ%2526p_cebc8%253QJrqarfqnl%2526p_rIne8%253QJrqarfqnl%2526p_cebc9%253QJrrxqnl%2526p_rIne9%253QJrrxqnl%2526p_rIne12%253QQverpg%2526p_rIne21%253Qao%2526p_rIne25%253QArgonax%2526p_rIne29%253QQverpg%2526p_cebc41%253QARG0006%2526p_rIne42%253Qao%25253Nybtba%25253Nybtba%2526p_cebc55%253Qao%25253Nybtba%25253Nybtba%2526q_egoq%253Qwfba%2526q_wfbai%253Q1%2526q_qfg%253Q1%2526q_pgf%253Q1%2526q_po%253QqrzqrkErdhrfgPnyyonpx1374655029179%2Cq91057nr72327302%2C96n91s93qqp26117%2C07822285229q55p0%2Crnn7pp7p19323853%2C%2C93585po36p66947r%2C%2C51q81786895s4s8r%2C%2C541843r4s3s042o9%3Bv%3D12%2C6qs311s0n255nqp3%2C11r31r0806ns7308%2C4qrp893o3q7s99n0%2Cpp02p1sr22817o6p%2C3o67p115p8sn7o75%2C2p284056oqo1onr4%2C80363q72nq5rnors%2C11sr371752rpq18s%2C6q765r40ros8oo4p%2C9opn3pn87s2135qo%2C289366rq9spnq31s%2C95s92o2s0po53054%3Be%3D15587%3B" name="perfmonLog" id="perfmonLog" type="hidden"> 
<div class="FieldElement FieldElementNoLabel"> 
<div class="CbaButton " id="btnLogon"> 
<input class="button field" name="btnLogon$field" value="LOG ON" id="btnLogon_field" type="submit"> 
</div> 
</div> 

回答