程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> 國家電網電費查詢,電網電費查詢

國家電網電費查詢,電網電費查詢

編輯:C#入門知識

國家電網電費查詢,電網電費查詢


 

  最近在老家出差,老家電網改革,使用了智能電表,把老式電表全部換了還給了一個客戶號,

終於也可以在支付寶什麼的交電費了,但我們那裡支付寶還不能查詢剩余多少錢,這讓人很惱火,

於是就來國家電網http://www.95598.cn/person/index.shtml 查詢了一下,發現需要客戶號、查詢密碼、驗證碼,客戶號我知道,查詢密碼是不知道的,隨便輸入,提示錯誤,

於是打95598問了下客服,得知了默認密碼是6個8,查詢了一下,出來消息了,但想每次都上電腦上查,貌似有點不方便,就想自己做一個模擬提交的,

模擬提交就要解決驗證碼識別的問題,看看也不復雜,就搗鼓了一會,然後分析提交的信息及url,

然後看到一個http://www.95598.cn/95598/per/shortCut/getShortCutAccount 這個地址,只傳了2個參數,一個客戶號,還有一個不知道是什麼,

就直接測試了下這個url,post提交了兩個參數,然後居然信息直接出來了,

還是josn格式。。。客戶名稱、電表地址、電表號,余額、違約金、欠費信息,還有部分類型的客戶居然還帶近期的電費記錄,

到這我就想問特麼你之前驗證的查詢密碼和驗證碼了 干什麼用的? 只是個慌子嗎?我書都的少,你別騙我,這麼大一個國家電網,居然這個查詢密碼是個渣?

好吧 代碼我也上上來吧,但沒什麼技術含量了

/// <summary>
        /// 獲取電費
        /// </summary>
        /// <param name="consNo">客戶號</param>
        /// <returns></returns>
        public static void GetPowerRate<T>(T consNo)
        {
            HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://www.95598.cn/95598/per/shortCut/getShortCutAccount");
            httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
            httpWebRequest.Method = "POST";
            var data = System.Text.Encoding.UTF8.GetBytes(string.Format("consNo={0}&orgNo=43101", consNo));
            using (Stream stream = httpWebRequest.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
                stream.Close();
            }
            data = null;
            Result result = new Result();
            try
            {
                HttpWebResponse webResponse = httpWebRequest.GetResponse() as HttpWebResponse;
                using (System.IO.StreamReader stream = new StreamReader(webResponse.GetResponseStream()))
                {
                    result = Newtonsoft.Json.JsonConvert.DeserializeObject<Result>(stream.ReadToEnd());
                }
                httpWebRequest = null;
                webResponse.Close();
                webResponse = null;
            }
            catch { }
            result.billInfo.consNo = consNo.ToString();
            Write(result);
        }

返回json 示例:

"{\"statusCode\":200,\"orgNo\":\"43101\",\"billInfo\":{\"errorCode\":null,\"count\":\"21\",\"errorMessage\":null,\"orgNo\":\"xxx52\",\"consNo\":\"1xxx4\",\"consName\":\"唐xx\",\"elecAddr\":\"岳麓-長沙市岳麓區望岳路xxx\",\"consSortCode\":\"城網低壓居民\",\"rtnCode\":null,\"rtnMsg\":null,\"acctOrgNo\":null,\"purchaseType\":\"普通繳費\",\"balLists\":[
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000360600225\",\"rcvblAmt\":\"27.64\",\"owePenalty\":\"0\",\"rcvedAmt\":\"27.64\",\"oweAmt\":\"0\",\"rcvblYm\":\"201412\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2015000384456503\",\"rcvblAmt\":\"27.64\",\"owePenalty\":\"0\",\"rcvedAmt\":\"27.64\",\"oweAmt\":\"0\",\"rcvblYm\":\"201501\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2015000417908221\",\"rcvblAmt\":\"1.76\",\"owePenalty\":\"0\",\"rcvedAmt\":\"1.76\",\"oweAmt\":\"0\",\"rcvblYm\":\"201503\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2015000458719783\",\"rcvblAmt\":\"32.93\",\"owePenalty\":\"0\",\"rcvedAmt\":\"32.93\",\"oweAmt\":\"0\",\"rcvblYm\":\"201505\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2015000475907830\",\"rcvblAmt\":\"33.52\",\"owePenalty\":\"0\",\"rcvedAmt\":\"33.52\",\"oweAmt\":\"0\",\"rcvblYm\":\"201506\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2015000494109461\",\"rcvblAmt\":\"114.13\",\"owePenalty\":\"0\",\"rcvedAmt\":\"114.13\",\"oweAmt\":\"0\",\"rcvblYm\":\"201507\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2015000517111477\",\"rcvblAmt\":\"84.67\",\"owePenalty\":\"0\",\"rcvedAmt\":\"5.87\",\"oweAmt\":\"78.8\",\"rcvblYm\":\"201508\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2015000400353270\",\"rcvblAmt\":\"11.76\",\"owePenalty\":\"0\",\"rcvedAmt\":\"11.76\",\"oweAmt\":\"0\",\"rcvblYm\":\"201502\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2015000435879133\",\"rcvblAmt\":\"8.23\",\"owePenalty\":\"0\",\"rcvedAmt\":\"8.23\",\"oweAmt\":\"0\",\"rcvblYm\":\"201504\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2013000201613636\",\"rcvblAmt\":\"148.59\",\"owePenalty\":\"0\",\"rcvedAmt\":\"148.59\",\"oweAmt\":\"0\",\"rcvblYm\":\"201312\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000206170080\",\"rcvblAmt\":\"288.76\",\"owePenalty\":\"0\",\"rcvedAmt\":\"288.76\",\"oweAmt\":\"0\",\"rcvblYm\":\"201401\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000213433834\",\"rcvblAmt\":\"178.57\",\"owePenalty\":\"0\",\"rcvedAmt\":\"178.57\",\"oweAmt\":\"0\",\"rcvblYm\":\"201402\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000220409307\",\"rcvblAmt\":\"0.59\",\"owePenalty\":\"0\",\"rcvedAmt\":\"0.59\",\"oweAmt\":\"0\",\"rcvblYm\":\"201403\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000224346917\",\"rcvblAmt\":\"9.41\",\"owePenalty\":\"0\",\"rcvedAmt\":\"9.41\",\"oweAmt\":\"0\",\"rcvblYm\":\"201404\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000235525969\",\"rcvblAmt\":\"22.34\",\"owePenalty\":\"0\",\"rcvedAmt\":\"22.34\",\"oweAmt\":\"0\",\"rcvblYm\":\"201405\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000250824152\",\"rcvblAmt\":\"24.7\",\"owePenalty\":\"0\",\"rcvedAmt\":\"24.7\",\"oweAmt\":\"0\",\"rcvblYm\":\"201406\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000265451425\",\"rcvblAmt\":\"32.34\",\"owePenalty\":\"0\",\"rcvedAmt\":\"32.34\",\"oweAmt\":\"0\",\"rcvblYm\":\"201407\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000287619069\",\"rcvblAmt\":\"100.55\",\"owePenalty\":\"0\",\"rcvedAmt\":\"100.55\",\"oweAmt\":\"0\",\"rcvblYm\":\"201408\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000302284130\",\"rcvblAmt\":\"97.02\",\"owePenalty\":\"0\",\"rcvedAmt\":\"97.02\",\"oweAmt\":\"0\",\"rcvblYm\":\"201409\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000329656994\",\"rcvblAmt\":\"34.1\",\"owePenalty\":\"0\",\"rcvedAmt\":\"34.1\",\"oweAmt\":\"0\",\"rcvblYm\":\"201410\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null},
{\"statusCode\":\"非鎖定\",\"rcvblAmtId\":\"2014000342784003\",\"rcvblAmt\":\"23.52\",\"owePenalty\":\"0\",\"rcvedAmt\":\"23.52\",\"oweAmt\":\"0\",\"rcvblYm\":\"201411\",\"rcvedPenalty\":null,\"billType\":\"正常電費\",\"addBal\":null}],
\"acctBal\":\"0\",\"chargeBal\":null,\"freezeBal\":null,\"oweAmtSum\":\"78.8\",\"owePenaltySum\":\"0\",\"purchaseInfos\":null,\"levDisBeginYm\":null,\"levDisEndYm\":null,\"levDisAmt\":null,\"isLevDisFlag\":null,\"limitReason\":null},\"date\":\"2015-08-18\"}"////

示例中部分信息被我用xx代替了,

字段說明:

consN(客戶號)、consName(客戶姓名)、elecAddr(電表地址)、consSortCode類型、 acctBal(賬戶余額)、oweAmtSum(賬戶欠費)、

statusCode 固定為200 不管客戶號有沒有都是200  然後就是billInfo消息中如果consNo(客戶號)為null則表示沒有客戶,

農村的返回稍微有點一樣,但關鍵信息都有,今天不搗鼓了,洗洗睡了

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved