MessageBox.Show((((DateTime.Now.ToUniversalTime().Ticks – 621355968000000000) / 10000)+1).ToString());
//((DateTime.Now.ToUniversalTime().Ticks – 621355968000000000) / 10000000).ToString())
HttpWebRequest htmlReq = (HttpWebRequest)HttpWebRequest.Create(“https://zc.yy.com/normalVcode/create.do?appid=1&random=”);
htmlReq.Proxy = null;//null为不设置代理
HttpWebResponse htmlRes=(HttpWebResponse) htmlReq.GetResponse();//请求网页并将返回参数给予htmlres
Stream stream = htmlRes.GetResponseStream();//创建流,并将网页返回参数转换成流赋予stream
try
{
picRes.Image = Image.FromStream(stream);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
stream.Close();
以上是代码。
try部分是报错的部分…
想学习一下关于自动登录以及注册方面的,这些完全不懂,看了一个视频,代码基本照抄了…
结果报错…
求个大大能否帮忙一下解释一下为什么报错?
实在不懂T.T
//((DateTime.Now.ToUniversalTime().Ticks – 621355968000000000) / 10000000).ToString())
HttpWebRequest htmlReq = (HttpWebRequest)HttpWebRequest.Create(“https://zc.yy.com/normalVcode/create.do?appid=1&random=”);
htmlReq.Proxy = null;//null为不设置代理
HttpWebResponse htmlRes=(HttpWebResponse) htmlReq.GetResponse();//请求网页并将返回参数给予htmlres
Stream stream = htmlRes.GetResponseStream();//创建流,并将网页返回参数转换成流赋予stream
try
{
picRes.Image = Image.FromStream(stream);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
stream.Close();
以上是代码。
try部分是报错的部分…
想学习一下关于自动登录以及注册方面的,这些完全不懂,看了一个视频,代码基本照抄了…
结果报错…
求个大大能否帮忙一下解释一下为什么报错?
实在不懂T.T
解决方案
20
public static Image doGetImg(string Url)
{
try
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(Url.ToString());
myRequest.ServicePoint.Expect100Continue = true;
myRequest.Method = "GET";
//if (!CommonTool.isEmpty(refUrl))
myRequest.Timeout = 30000;
myRequest.KeepAlive = true;
myRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)";
myRequest.ContentType = "application/x-www-form-urlencoded";
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
return Bitmap.FromStream(myResponse.GetResponseStream());
}
catch
{
return null;
}
}