using (System.Net.Http.HttpClient httpClient = new HttpClient())
{
httpClient.MaxResponseContentBufferSize = 256000;
httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36");
httpClient.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
Console.WriteLine($"登录提交:");
var response = httpClient.PostAsJsonAsync("http://xxxxx/account/login", new User() { account = @"admin", password = @"admin" }).Result;
Console.WriteLine($"Response:{response.Content.ReadAsStringAsync().Result}");
Console.WriteLine($"主界面:");
var get = httpClient.GetAsync("http://xxxxx/#pane=Dashboard");
get.Wait(1000);
Console.WriteLine($"弹窗界面:");
DateTime curr = new DateTime(2019, 12, 6);
string name = $"{curr:yyyy-MM-dd}";
Console.WriteLine($"取记录=>{name}:");
get = httpClient.GetAsync("http://xxxxx/Report/AddReport?Date=" + name + "&type=add");
//将 html 写入到本地
Write(name + ".html", get.Result.Content.ReadAsStringAsync().Result);
Console.WriteLine(get.Result.Content.ReadAsStringAsync().Result);
}
}
Console.WriteLine($"重复值:{item.dailyContent}");
var id = li.FirstOrDefault(q => q.dailyContent == item.dailyContent)?.dailyDetailId;
Console.WriteLine($"首个Id:{id}");
Dictionary<string, string> del = new Dictionary<string, string>();
del.Add("Id",id);
var ppp= httpClient.PostAsync("http://xxxxx/Report/Delete", new FormUrlEncodedContent(del)).Result;
Console.WriteLine($"删除状态:{ppp.StatusCode == System.Net.HttpStatusCode.OK}");