zoukankan      html  css  js  c++  java
  • c# 获取网站验证码图片

    代码
    /// <summary>
    /// 获取网页验证码
    /// </summary>
    /// <param name="server">服务器地址</param>
    /// <param name="URL">网页地址</param>
    /// <param name="byteRequest">字节数组,存放图片字节</param>
    /// <param name="cookie">网站分配给客户的临时sessionid(临时cookie值),并非真正cookie</param>
    /// <param name="header"></param>
    /// <returns>图片的二进制数组</returns>
    public static byte[] GetHtmlByBytes(string server, string URL, byte[] byteRequest, string cookie, out string header)
    {
    long contentLength;
    HttpWebRequest httpWebRequest;
    HttpWebResponse webResponse;
    Stream getStream;

    httpWebRequest
    = (HttpWebRequest)HttpWebRequest.Create(URL);
    CookieContainer co
    = new CookieContainer();
    co.SetCookies(
    new Uri(server), cookie);
    httpWebRequest.CookieContainer
    = co;
    httpWebRequest.ContentType
    = "application/x-www-form-urlencoded";
    httpWebRequest.Method
    = "Post";
    httpWebRequest.ContentLength
    = byteRequest.Length;
    Stream stream;
    stream
    = httpWebRequest.GetRequestStream();
    stream.Write(byteRequest,
    0, byteRequest.Length);
    stream.Close();
    webResponse
    = (HttpWebResponse)httpWebRequest.GetResponse();
    header
    = webResponse.Headers.ToString();
    getStream
    = webResponse.GetResponseStream();
    contentLength
    = webResponse.ContentLength;

    byte[] outBytes = new byte[contentLength];
    outBytes
    = ReadFully(getStream);
    getStream.Close();
    return outBytes;
    }
  • 相关阅读:
    as3 return语句中的运算符
    AIR custom ApplicationUpdaterUI
    Flash Builder 无法连接到应用程序以访存概要分析数据
    Android的所有权限说明
    Tomcat数据源配置
    hibernate 延迟加载(懒加载)
    Android SQLite数据库操作
    Android下载文本文件和mp3文件
    JPA注解
    Android Intent传值且实现窗体跳转
  • 原文地址:https://www.cnblogs.com/daretodream/p/1700722.html
Copyright © 2011-2022 走看看