自己动手丰衣足食,亲测可用,提问的时间干嘛不自己试一下呢?
[C#] 纯文本查看 复制代码 private string GetHttp20210629105649()
{
SufeiUtil.HttpHelper http = new SufeiUtil.HttpHelper();
SufeiUtil.HttpItem item = new SufeiUtil.HttpItem()
{
URL = "https://2724783958-wc.qq168.ws/code?_=1624336028178",
Method = "GET",
Host = "2724783958-wc.qq168.ws",
UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
ResultType = SufeiUtil.ResultType.Byte
};
item.Header.Add("Sec-Fetch-Site", "none");
item.Header.Add("Sec-Fetch-Mode", "navigate");
item.Header.Add("Sec-Fetch-User", "?1");
item.Header.Add("Sec-Fetch-Dest", "document");
item.Header.Add("Accept-Encoding", "gzip, deflate, br");
item.Header.Add("Accept-Language", "zh-CN,zh;q=0.9");
SufeiUtil.HttpResult result = http.GetHtml(item);
System.Drawing.Image img = byteArrayToImage(result.ResultByte);
string Temp = System.AppDomain.CurrentDomain.BaseDirectory + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
img.Save(Temp);
return Temp;
//string html = result.Html;
//return html;
}
/// <summary>
/// 字节数组生成图片
/// </summary>
/// <param name="Bytes">字节数组</param>
/// <returns>图片</returns>
private System.Drawing.Image byteArrayToImage(byte[] Bytes)
{
MemoryStream ms = new MemoryStream(Bytes);
return System.Drawing.Bitmap.FromStream(ms, true);
}
private void Btn_get_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(GetHttp20210629105649());
} |