以编程方式获取页面截图 [英] Programmatically get a screenshot of a page

查看:214
本文介绍了以编程方式获取页面截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写内部使用一个专门的履带式和分析器,我需要采取一个网页的截图,以便在整个检查正在使用什么颜色的能力。该计划将在十点左右网页地址,并将它们保存为位图图像。

I'm writing a specialized crawler and parser for internal use, and I require the ability to take a screenshot of a web page in order to check what colours are being used throughout. The program will take in around ten web addresses and will save them as a bitmap image.

从那里我打算以创建图像内的五个最常用的颜色的列表使用LockBits。据我所知,这是获得一个网页中使用的颜色最简单的方法,但如果有一个更简单的方法来做到这一点,请附和你的建议。

From there I plan to use LockBits in order to create a list of the five most used colours within the image. To my knowledge, it's the easiest way to get the colours used within a web page, but if there is an easier way to do it please chime in with your suggestions.

反正我是要使用的 ACA WebThumb ActiveX控件 的直到我看到价格标签。我也相当新的C#中,有只用它了几个月。有没有我采取一个网页的截图,以提取颜色方案问题的解决方案?

Anyway, I was going to use ACA WebThumb ActiveX Control until I saw the price tag. I'm also fairly new to C#, having only used it for a few months. Is there a solution to my problem of taking a screenshot of a web page in order to extract the colour scheme?

推荐答案

只需使用 Websnapr 。你可以做10万张/月。还有的是,不应该影响你的颜色(如果这样做,就是不拿右下角考虑)一个小小的水印。额外的好处是,他们有最流行的网址缓存,所以你会得到非常快的响应时间。

Just use Websnapr. You can do 100,000 images / month. There is a tiny little watermark that should not influence your colors (if it does, just don't take the bottom right corner into account). The added benefit is that they have most popular URLs cached, so you will get very fast response times.

您需要使用HttpWebRequest的下载图像的二进制文件。这里有一个例子:

You'll need to use HttpWebRequest to download the binary of the image. Here's an example:

    HttpWebRequest request = HttpWebRequest.Create("http://images.websnapr.com/?size=s&url=http%3A%2F%2Fwww.google.com") as HttpWebRequest;
    Bitmap bitmap;
    using (Stream stream = request.GetResponse().GetResponseStream())
    {
        bitmap = new Bitmap(stream);
    }
    // now that you have a bitmap, you can do what you need to do...

我不跟ACA系统无关。

I am not affiliated with ACA Systems.

这篇关于以编程方式获取页面截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆