我正在尝试下载每次加载时都会发生变化的图像.在src该属性img标记是恒定的,但所显示的图像的变化(我猜的Web应用程序在改变图像src上的每一击).
我尝试下载使用src,并返回的图像是不同的,如预期的那样.
我的要求是下载页面上显示的图像.我也尝试右键单击保存,但在页面中禁用了右键单击.有任何想法吗 ?我正在使用selenium webdriver.Other选项也很受欢迎.
这是我尝试使用该src属性:
public static void download() {
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://*******.com/");
String url = driver.findElement(By.id("regImg")).getAttribute("src");
// run of the mill code to download the image.
downloadImage(url);
}
Run Code Online (Sandbox Code Playgroud)
正如我所说,这段代码有效,但我得到了一个不同的图像,因为网络应用程序在每次点击时都会更改它.我需要页面上显示的那个.
这是HTML:
<td width="20%" align="center" class="style1">characters
<font color="#FF0000">*</font>
<img id="regImg" src="../../**/**.php" alt="captcha image" height="25">
</td>
Run Code Online (Sandbox Code Playgroud) 我尝试设置 chrome 代理:
google-chrome --proxy-server=127.0.0.1:8888
Run Code Online (Sandbox Code Playgroud)
Chrome 打开一个新窗口,但 charles 没有捕获任何窗口。