輸入銀行卡號查詢髮卡行執行代碼-立哥開發

#Copy Right by Jacky Zong . Vision 1.5
from bs4 import BeautifulSoup
import urllib2
import json

ALI_BANKS = ‘http://ab.alipay.com/i/yinhang.htm’

try:
response = urllib2.urlopen(ALI_BANKS)
except urllib2.HTTPError, e:
print “HTTP Error %s : %s” % (e.code, e.reason)
system.exit(1)
except urllib2.URLError, e:
print “Unable to connect the remote server.”
system.exit(1)

content = response.read()

soup = BeautifulSoup(content)
spans = soup.find_all(“span”, class_=“icon”)

banks = {}

for span in spans:

banks[span[‘class’][1]] = span.text

banks = { span[‘class’][1] : span.text for span in spans }

print json.dumps(banks, ensure_ascii=False, indent=2)
print “total : %d” % len(banks)

Connection: keep-alive
Content-Language: zh-CN
Content-Length: 101
Content-Type: application/json;charset=GBK
Date: Sun, 08 Mar 2015 15:21:17 GMT
Server: spanner/1.0.6
Set-Cookie: JSESSIONID=CCDE8AA9E2DAEC082A7614734AF729FB; Path=/; HttpOnly
Set-Cookie: JSESSIONID=CCDE8AA9E2DAEC082A7614734AF729FB; Path=; Secure; HttpOnly
Set-Cookie: spanner=dauWw2JHEhbWoKV/zrMf2LLFCxFf8h1G;path=/;secure;
Strict-Transport-Security: max-age=31536000

{
“bank”: “Citi Bank”,
“cardType”: “DC”,
“key”: “622843012000000XXXXX”,
“messages”: [],
“stat”: “ok”,
“validated”: true
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章