各位好,我目前遇到的問題是我想去證交所抓信用交易資料
使用以下的程式碼
string url = "https://wwwc.twse.com.tw/zh/exchangeReport/MI_MARGN";
var client = new RestClient(url);
var request = new RestRequest("",Method.Get);
request.AddHeader("Accept", "*/*");
request.AddHeader("Accept-Encoding", "gzip, deflate, br");
request.AddHeader("Accept-Language",
"zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7");
request.AddHeader("Connection", "keep-alive");
request.AddHeader("Content-Length", "42");
request.AddHeader("Content-Type",
"application/x-www-form-urlencoded; charset=UTF-8");
request.AddHeader("Cookie", "_ga=_ga=GA1.3.228088691.1674099947;
_gid=GA1.3.1638277859.1674099947;
JSESSIONID=E0D3F21B26722058423036EA82A061FE; _gat=1");
request.AddHeader("Host", "wwwc.twse.com.tw");
request.AddHeader("Origin", "https://wwwc.twse.com.tw");
request.AddHeader("Referer",
"https://wwwc.twse.com.tw/zh/page/trading/exchange/MI_MARGN.html");
request.AddHeader("sec-ch-ua", "'Not_A Brand';v='99', 'Google
Chrome';v='109', 'Chromium';v='109'");
request.AddHeader("sec-ch-ua-mobile", "?0");
request.AddHeader("sec-ch-ua-platform", "'Windows'");
request.AddHeader("Sec-Fetch-Dest", "empty");
request.AddHeader("Sec-Fetch-Mode", "cors");
request.AddHeader("Sec-Fetch-Site", "same-origin");
request.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0;
Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0
Safari/537.36");
request.AddHeader("X-Requested-With", "XMLHttpRequest");
RestResponse response = client.Execute(request);
AddInfo(response.Content.ToString());
但是會一直出現回傳是null的狀態,但是我使用開發人員工具來看這是我在取得分類項目"全部"的需求header,請問這裡面是否有我漏掉的部分呢?
感謝各位的解惑