zoukankan      html  css  js  c++  java
  • WebBrowser示例

            [STAThread]
            static void Main(string[] args)
            {
                System.Console.WriteLine("Create your own web history images.");
                System.Console.WriteLine("Type the URL (with http://...");
                string url = System.Console.ReadLine();
                System.Console.WriteLine(@"Save to location (e.g. C:\Images\)");
                string path = System.Console.ReadLine();
                IArchiveService service = new WebArchiveService();
                Website result = service.Load(url);
                System.Console.WriteLine("WebArchive Sites found: " + result.ArchiveWebsites.Count);
                WebBrowser wb = new WebBrowser();
                int i = 0;
                foreach (ArchiveWebsite site in result.ArchiveWebsites)
                {
                 i++;
                 System.Console.WriteLine("Save image (Date " + site.Date.ToShortDateString() + ") number: " + i.ToString());
                 wb.ScrollBarsEnabled = false;
                 wb.ScriptErrorsSuppressed = true;
                 wb.Navigate(site.ArchiveUrl);
                 while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
                 wb.Width = wb.Document.Body.ScrollRectangle.Width;
                 wb.Height = wb.Document.Body.ScrollRectangle.Height;
    
                 Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
                 wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
                 bitmap.Save(path + site.Date.Year.ToString() + "_" + site.Date.Month.ToString() + "_" + site.Date.Day.ToString() + ".bmp");
                }
                wb.Dispose();
    
                System.Console.WriteLine(result.Url);
            }
    作者:KKcat
        
    个人博客:http://jinzhao.me/
        
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    如何使用Doxygen生成keil工程的代码文档 (how to use doxygen properly with keil)
    使用matlab画相交的平面
    转载:关于循环异步操作 Promise 实现,ES7 的 await 和 async
    小众软件:相见恨晚的 Windows 系统下的 cmd 的命令行替代者 Cmder(完美神器)
    Windows系统环境下Python脚本实现全局“划词复制”功能
    Ubuntu shell 命令行路径缩短
    shell查找数组是否有特定的值
    保存数据到文件
    左值与右值
    进程与线程的区别
  • 原文地址:https://www.cnblogs.com/jinzhao/p/1430417.html
Copyright © 2011-2022 走看看