天天看點

身份證查詢API

# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#http://apistore.baidu.com/apiworks/servicedetail/113.html
#身份證查詢API



import urllib,json,urllib2
#接口位址
url=\'http://apis.baidu.com/apistore/idservice/id?\'#注意問号


#請求方法:GET

#urlParam,url參數
data={\'id\':\'xxxxxx\'}#身份證号碼
#編碼
data=urllib.urlencode(data)
MyUrl=url+data


#header,頭部資訊
#記住添加頭部資訊的方法
req=urllib2.Request(MyUrl)
req.add_header(\'apikey\',\'75ea5c11d0461f15791c1398a05369b7\')
resp=urllib2.urlopen(req)
content=resp.read()
content=eval(content)
print content.values()