翔賀通運有限公司

派件 – 面單自有系統抓新竹到站碼站 ( 簡體 ) 網頁

HCT 到著站網頁

到著站網址:
http://is1fax.hct.com.tw:8080/GET_ERSTNO/Addr_Compare_Simp.aspx?addr=%e9%ab%98%e9%9b%84%e5%b8%82%e5%b7%a6%e8%90%a5%e5%8c%ba%e5%8d%8e%e5%a4%8f%e8%b7%af238%e5%8f%b7

請先將簡體中文轉為 UrlDecode 碼 (c# 範例 )
//addr = “高雄市左营区华夏路238号”;
//addr = System.Web.HttpUtility.UrlEncode(addr, Encoding.UTF8); //轉換UrlDecode碼
//轉換UrlDecode碼:%e9%ab%98%e9%9b%84%e5%b8%82%e5%b7%a6%e8%90%a5%e5%8c%ba%e5%8d%8e%e5%a4%8f%e8%b7%af238%e5%8f%b7

實際取得字串內容:
送貨地址:高雄市左營區華夏路238號<BR>到著站四碼:6108<BR>到著站簡碼:82  <BR>到著站中文:高雄    <BR>郵遞區號:804<BR>

C# 範例程式:
            WebClient client = new WebClient();
            addr = “http://is1fax.hct.com.tw:8080/GET_ERSTNO/Addr_Compare.aspx?addr=” + HttpUtility.UrlEncode(addr, Encoding.GetEncoding(“big5”));

            byte[] bResult = client.DownloadData(addr);
            string result = Encoding.GetEncoding(950).GetString(bResult);

            string[] erstno = new string[3];
            erstno[0] = result.Substring(result.IndexOf(“到著站簡碼:”) + 6, 3); // 列印標籤上的 ” 到著站號碼 ”
            erstno[0] = (erstno[0].IndexOf(‘<‘) > -1) ? erstno[0].Substring(0, erstno[0].IndexOf(‘<‘)) : erstno[0];
            erstno[1] = result.Substring(result.IndexOf(“到著站四碼:”) + 6, 4);
            erstno[2] = result.Substring(result.IndexOf(“郵遞區號:”) + 5, 3);

            int resultInt = 0;
            if (!int.TryParse(erstno[0], out resultInt))
                erstno[0] = “”;