|
get后 转成byte类型保存本地的图片也查看不了 应该是代码错了 不知道怎么写 求解
using System;
using System.Text;
using System.Net;
using System.IO;
using FastVerCode;
using System.Net;
namespace ConsoleApp17
{
class Program
{
public static CookieContainer mycookie=new CookieContainer();
static void Main(string[] args)
{
Console.Write(code("http://www.606yl.com/vcode.php?v=1423393581", "www.606yl.com"));
}
public static string code(string url,string host)
{
HttpWebRequest http = (HttpWebRequest)WebRequest.Create(url);
http.Method = "GET";
http.Accept = "image/webp,image/apng,image/*,*/*;q=0.8";
http.Host = host;
http.Referer = "http://www.606yl.com/reg.html";
http.CookieContainer = mycookie;
HttpWebResponse re = (HttpWebResponse)http.GetResponse();
foreach (Cookie cookie in re.Cookies)
mycookie.SetCookies(new Uri(url), ("" + cookie.Name + "=" + cookie.Value));
StreamReader item = new StreamReader(re.GetResponseStream(), Encoding.Default);
string username = "***";
string pwd = "***";
string softKey = "***";
//获取用户信息
string userInfo = VerCode.GetUserInfo(username, pwd);
byte[] bytes = Encoding.Default.GetBytes(item.ReadToEnd()); /////应该就是这里的问题 但是不知道怎么解决 获取的方式不正确吗?
//上传字节集验证码
string returnMess = VerCode.RecByte_A(bytes, bytes.Length, username, pwd, softKey);
//上传本地验证码
System.Diagnostics.Debug.WriteLine(returnMess);
return returnMess;
}
}
}
|
|