Ich mache einen Proxy-Checker in Selen, gibt es eine Möglichkeit, ich kann es auf den nächsten Proxy gehen, wenn es dauert mehr als 15 Sekunden zu laden?Java Selen Timeout Seite
Also, wenn es die frist-Proxy versucht, dauert es 15 Sekunden oder länger, lädt nur auf den nächsten Proxy bewegen
package a;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.*;
public class main {
public static void main(String[] args) throws IOException, InterruptedException {
BufferedReader br = new BufferedReader(new FileReader("proxy.txt"));
String line;
BufferedWriter file = null;
file = new BufferedWriter(new FileWriter("proxy_out.txt"));
while ((line = br.readLine()) != null) {
//splitting
String str;
str = line;
String[] splited = line.split(":");
//System.out.println(Arrays.toString(splited));
String IP = splited[0];
String PORT = splited[1];
System.out.println(IP + ":" + PORT);
String PROXY = IP + ":" + PORT;
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
.setFtpProxy(PROXY)
.setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new ChromeDriver(cap);
driver.get("google.com");
try {
WebElement Check = driver.findElement(By.id("input_captcha"));
if (Check.isDisplayed()) {
System.out.println(PROXY + " is good");
file.write(IP+":"+PORT);
}
} catch (Exception e) {
System.out.println("Bad");
}
driver.close();
}
file.close();
}
}
Schöne Frage. Es gibt? – statosdotcom
Was meinst du? – azelia