使用硒保存页面中的图像 [英] Using selenium to save images from page

查看:90
本文介绍了使用硒保存页面中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium& Google Chrome驱动程序以编程方式打开页面。每个页面上都有一个动态生成的图像,我想下载该图像。目前,我正在等待页面完成加载,然后获取图像URL并使用System.Net.WebClient下载。

I'm using Selenium & Google Chrome Driver to open pages programatically. On each page there is a dynamically generated image which I'd like to download. At the moment, I'm waiting for the page to finish loading, then I grab the image URL and download it using System.Net.WebClient.

除了可以正常工作外我要下载图像两次-在浏览器中一次,在WebClient中一次。问题是每个图像大约有15MB,下载两次会很快增加。

That works fine except I'm downloading the images twice - once in the browser, once with WebClient. The problem is that each image is roughly 15MB and downloading twice adds up quickly.

所以-是否可以直接从Google Chrome浏览器中获取图像?

So - is it possible to grab the image straight from Google Chrome?

推荐答案

您可以使用技术。它运行称为块图像的Google Chrome扩展程序。这样一来,图片将不会使用chrome下载,而只需使用其网址和地址正常下载图片即可。 System.Net.WebClient。

You can block images from being downloaded in Google Chrome using this technique. It runs a Google Chrome extension called "Block Image". This way the image won't be downloaded using chrome, and it's just a matter of downloading the image as normal using its URL & System.Net.WebClient.

这篇关于使用硒保存页面中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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