[C#]WebClient抓銀行碼

以前拿webClient玩過爬蟲,剛好遇到公司要抓銀行碼就利用

財金資訊股份有限公司的開放資料,結果卡在proxy設定就記錄一下好了

try {
    WebClient wc = new WebClient();
    StringBuilder sb = new StringBuilder();

    //設定proxy,沒有的話直接註解掉
    WebProxy wp = new WebProxy("proxy.XXX.com.tw", 80);
    wp.Credentials = new NetworkCredential("userName", "userPassword");
    wc.Proxy = wp;


    Stream web_stream = wc.OpenRead(@"http://www.fisc.com.tw/TC/OPENDATA/Comm1_MEMBER.csv");
    StreamReader sr = new StreamReader(web_stream, Encoding.UTF8);
    while (!sr.EndOfStream) {
        sb.Append(sr.ReadLine).Append(("" + "\r\n"));
    }
    
    string ss = sb.ToString();
    sr.Dispose();
    web_stream.Dispose();
    web_stream.Close();
    sr.Close();
}
catch (Exception ex) {
    
}