Created
May 18, 2019 05:17
-
-
Save edwin/49be66615237a506498c72ccff1cb6c9 to your computer and use it in GitHub Desktop.
"robot" untuk simpan screenshot web hitung suara kpu (pemilu2019.kpu.go.id) setiap 10 detik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.edw.situng; | |
import org.apache.commons.io.FileUtils; | |
import org.openqa.selenium.OutputType; | |
import org.openqa.selenium.TakesScreenshot; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import java.io.File; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
/** | |
* | |
* @author Muhammad Edwin < edwinkun at gmail dot com > | |
* 18 May 2019 11:46 | |
*/ | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
System.setProperty("webdriver.gecko.driver","E:\\software\\GeckoDriver\\geckodriver.exe"); | |
WebDriver driver = null; | |
for (int i = 0; i < 10; i++) { | |
driver = new FirefoxDriver(); | |
driver.manage().window().fullscreen(); | |
driver.get("https://pemilu2019.kpu.go.id/#/ppwp/hitung-suara/"); | |
Thread.sleep(2000); | |
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); | |
FileUtils.copyFile(scrFile, new File("E:\\tmp\\"+new SimpleDateFormat("yyyyMMddHHmmSS").format(new Date()) +".situng.png")); | |
Thread.sleep(8000); | |
driver.close(); | |
} | |
if(driver != null ) | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pom-nya ketinggalan