zoukankan      html  css  js  c++  java
  • C# 获取动态验证码?

    如何获取动态验证码(比如登录验证码,每次访问码值都是不一样的)。本来想从cookie上入手但是,每次访问虽然码值不一样,但是后来发现它们的cookie一样的。这个道路就行不通了。

    目前知道一个解决方案,就是通过WebBrowser获取然后显示的html,1、种方法直接截图;2、将图片元素的DomElement作为参数,方法如下。但是这种方法效率太低..,求高效的方法。
    结合mshtml.dll.

    [ComImport, InterfaceType((short)1), Guid("3050F669-98B5-11CF-BB82-00AA00BDCE0B")]
    private interface IHTMLElementRenderFixed
    {
    void DrawToDC(IntPtr hdc);
    void SetDocumentPrinter(string bstrPrinterName, IntPtr hdc);
    }
    public Bitmap GetImage(object obj)
    {
    IHTMLImgElement img = (IHTMLImgElement)obj;
    IHTMLElementRenderFixed render = (IHTMLElementRenderFixed)img;
    
    Bitmap bmp = new Bitmap(img.width, img.height);
    Graphics g = Graphics.FromImage(bmp);
    IntPtr hdc = g.GetHdc();
    render.DrawToDC(hdc);
    g.ReleaseHdc(hdc);
    return bmp;
    }
    

      

  • 相关阅读:
    zabbix监控nginx的性能
    常用iptables命令
    shell脚本小示例
    打印菜单脚本
    ping主机脚本
    Linux网络配置脚本
    多磁盘自动分区自动挂载脚本
    深入js系列-类型(null)
    深入js系列-类型(开篇)
    first-child、last-child误解
  • 原文地址:https://www.cnblogs.com/wangn/p/3721258.html
Copyright © 2011-2022 走看看