Skip to content

Commit

Permalink
Now it can fully automatic screenshot as many as your pc can handle (…
Browse files Browse the repository at this point in the history
…no cap).

Just change the App.config and add the title, the link and how many websites you want to screenshots
  • Loading branch information
brotherzhafif committed Oct 9, 2022
1 parent b9ad623 commit 958aab6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 90 deletions.
40 changes: 21 additions & 19 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@

<appSettings>

<add key="Antang Kalang" value="https://www.windy.com/-1.363/112.546/meteogram?gfs,-1.465,112.546,11,m:dCSajiJ"/>
<add key="Baamang" value="https://www.windy.com/-2.540/112.946/meteogram?gfs,-2.642,112.946,11,m:dAVajjp"/>
<add key="Bukit Sentuai" value="https://www.windy.com/-1.759/112.270/meteogram?gfs,-1.862,112.270,11,m:dCfajii"/>
<add key="Cempaga" value="https://www.windy.com/-2.306/113.036/meteogram?gfs,-2.408,113.036,11,m:dBkajjy"/>
<add key="Cempaga Hulu" value="https://www.windy.com/-1.821/112.986/meteogram?gfs,-2.644,112.983,8,m:dB6ajjt"/>
<add key="Kota Besi" value="https://www.windy.com/-2.381/112.977/meteogram?gfs,-2.484,112.977,11,m:dBcajjs"/>
<add key="Mentawa Baru Ketapang" value="https://www.windy.com/-2.636/112.924/meteogram?gfs,-2.738,112.924,11,m:dALajjn"/>
<add key="Mentaya Hilir Selatan" value="https://www.windy.com/-2.930/112.880/meteogram?gfs,-3.033,112.880,11,m:dAiajjj"/>
<add key="Mentaya Hilir Utara" value="https://www.windy.com/-2.790/112.860/meteogram?gfs,-2.893,112.859,11,m:dAwajjh"/>
<add key="Mentaya Hulu" value="https://www.windy.com/-1.937/112.431/meteogram?gfs,-2.759,112.431,8,m:dBVajiy"/>
<add key="Parenggean" value="https://www.windy.com/-2.035/112.729/meteogram?gfs,-2.137,112.729,11,m:dBLaji1"/>
<add key="Pulau Hanaut" value="https://www.windy.com/-2.857/113.025/meteogram?gfs,-2.935,113.025,11,m:dApajjx"/>
<add key="Seranau" value="https://www.windy.com/-2.622/113.094/meteogram?gfs,-2.725,113.094,11,m:dAMajjE"/>
<add key="Telaga Antang" value="https://www.windy.com/-1.530/112.530/meteogram?gfs,-1.632,112.530,11,m:dCCajiH"/>
<add key="Telawang" value="https://www.windy.com/-2.388/112.519/meteogram?gfs,-2.491,112.519,11,m:dBcajiG"/>
<add key="Teluk Sampit" value="https://www.windy.com/-3.210/112.870/meteogram?gfs,-3.415,112.869,10,m:dzOajji"/>
<add key="Tualan Hulu" value="https://www.windy.com/-1.867/112.774/meteogram?gfs,-1.969,112.774,11,m:dB2aji6"/>
<add key="Kuala Pembuang" value="https://www.windy.com/-3.387/112.543/meteogram?gfs,-4.207,112.544,8,m:dzwajiJ"/>
<add key="Seruyan Hilir" value="https://www.windy.com/-3.254/112.434/meteogram?gfs,-3.459,112.434,10,m:dzJajiy"/>
<add key="link0" value="https://www.windy.com/-1.363/112.546/meteogram?gfs,-1.465,112.546,11,m:dCSajiJ"/>
<add key="link1" value="https://www.windy.com/-2.540/112.946/meteogram?gfs,-2.642,112.946,11,m:dAVajjp"/>
<add key="link2" value="https://www.windy.com/-1.759/112.270/meteogram?gfs,-1.862,112.270,11,m:dCfajii"/>
<add key="link3" value="https://www.windy.com/-2.306/113.036/meteogram?gfs,-2.408,113.036,11,m:dBkajjy"/>
<add key="link4" value="https://www.windy.com/-1.821/112.986/meteogram?gfs,-2.644,112.983,8,m:dB6ajjt"/>
<add key="link5" value="https://www.windy.com/-2.381/112.977/meteogram?gfs,-2.484,112.977,11,m:dBcajjs"/>
<add key="link6" value="https://www.windy.com/-2.636/112.924/meteogram?gfs,-2.738,112.924,11,m:dALajjn"/>
<add key="link7" value="https://www.windy.com/-2.930/112.880/meteogram?gfs,-3.033,112.880,11,m:dAiajjj"/>
<add key="link8" value="https://www.windy.com/-2.790/112.860/meteogram?gfs,-2.893,112.859,11,m:dAwajjh"/>
<add key="link9" value="https://www.windy.com/-1.937/112.431/meteogram?gfs,-2.759,112.431,8,m:dBVajiy"/>
<add key="link10" value="https://www.windy.com/-2.035/112.729/meteogram?gfs,-2.137,112.729,11,m:dBLaji1"/>
<add key="link11" value="https://www.windy.com/-2.857/113.025/meteogram?gfs,-2.935,113.025,11,m:dApajjx"/>
<add key="link12" value="https://www.windy.com/-2.622/113.094/meteogram?gfs,-2.725,113.094,11,m:dAMajjE"/>
<add key="link13" value="https://www.windy.com/-1.530/112.530/meteogram?gfs,-1.632,112.530,11,m:dCCajiH"/>
<add key="link14" value="https://www.windy.com/-2.388/112.519/meteogram?gfs,-2.491,112.519,11,m:dBcajiG"/>
<add key="link15" value="https://www.windy.com/-3.210/112.870/meteogram?gfs,-3.415,112.869,10,m:dzOajji"/>
<add key="link16" value="https://www.windy.com/-1.867/112.774/meteogram?gfs,-1.969,112.774,11,m:dB2aji6"/>
<add key="link17" value="https://www.windy.com/-3.387/112.543/meteogram?gfs,-4.207,112.544,8,m:dzwajiJ"/>
<add key="link18" value="https://www.windy.com/-3.254/112.434/meteogram?gfs,-3.459,112.434,10,m:dzJajiy"/>

<add key="0" value="Baamang"/>
<add key="1" value="Antang Kalang"/>
Expand All @@ -45,6 +45,8 @@


<add key="dir" value="Saved\\"/>
<add key="jumlah" value="20"/>
<add key="judul" value="Windy.com"/>

</appSettings>

Expand Down
119 changes: 48 additions & 71 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ namespace WebScreenshot
internal class Program
{

public static string dir = DateTime.Now.ToString("dd" + " MMMM" + " yyyy");
public static string dir = GetSetting("dir").ToString() + DateTime.Now.ToString("dd" + " MMMM" + " yyyy");
public static string nama = "";
public static string link = "";
public static string Y;

static void Main(String[] args)
{
Console.Title = "BMKG - Web Auto Screenshot By Zhafif Sekarang Jam " + DateTime.UtcNow.ToString() + " UTC+ ";
Console.Title = "Web Auto Screenshot By Zhafif " + DateTime.UtcNow.ToString() + " UTC+ ";
Console.BackgroundColor = ConsoleColor.DarkBlue;
Console.Clear();

Expand All @@ -31,32 +32,17 @@ static void Main(String[] args)

Console.WriteLine("Jadi Anda Mau Ngescreenshot Web Apa Hari Ini ?");
Console.WriteLine("");

bool loop = true;



LOOPING(Y);
Console.WriteLine(Y);
}
private static void LOOPING(string Y)
{
Console.WriteLine("Ketik Y untuk Screenshot Web Costume");
Console.WriteLine("Ketik W untuk Screenshot Web Windy.com Untuk Arsip BMKG");
Console.WriteLine("Ketik W untuk Screenshot Web "+GetSetting("judul"));
Console.WriteLine("Ketik N Atau C Atau E untuk Keluar");
Y = Console.ReadLine();

string Y = Console.ReadLine();

if (loop = true)
{
while (true)
{
LOOPING(Y, loop);
break;
Console.WriteLine(Y);
}
}
else
{
Environment.Exit(0);
}
}
private static bool LOOPING(string Y, bool loop)
{
if (Y == "y" || Y == "Y")
{
CaptureCosutmeLink();
Expand All @@ -65,19 +51,15 @@ private static bool LOOPING(string Y, bool loop)
{
CaptureWebPage();
}
else if (Y == "a")
{
loop = true;
}
else if (Y == "n" || Y == "N" || Y == "c" || Y == "C" || Y == "e" || Y == "E")
{
Environment.Exit(0);
}
else
{
loop = false;
Console.WriteLine("Tolong Ketik Pilihan Yang Tersedia Saja");
LOOPING(Y);
}
return loop;
}

private static void CaptureCosutmeLink()
Expand Down Expand Up @@ -115,16 +97,17 @@ private static void CaptureCosutmeLink()
Console.WriteLine("Memproses Tampilan Website " + nama, Console.ForegroundColor = ConsoleColor.White);
driver.Navigate().GoToUrl(link);
ITakesScreenshot screenshotDriver = driver as ITakesScreenshot;

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
Thread.Sleep(10000);
wait.Until(ExpectedConditions.ElementIsVisible(By.TagName("img")));

Screenshot screenshot = screenshotDriver.GetScreenshot();
screenshot.SaveAsFile(GetSetting(dir) + dir + "\\" + nama + ".png");
screenshot.SaveAsFile(dir + "\\" + nama + ".png");

Console.WriteLine(nama + " Telah Berhasil di Save");
driver.Close();

LOOPING(Y);
}

private static void CaptureWebPage()
Expand All @@ -146,57 +129,51 @@ private static void CaptureWebPage()

IWebDriver driver = new ChromeDriver(options);

string[] Links = new string[]
{
GetSetting("Baamang"),
GetSetting("Antang Kalang"),
GetSetting("Bukit Sentuai"),
GetSetting("Cempaga"),
GetSetting("Cempaga Hulu"),
GetSetting("Kota Besi"),
GetSetting("Mentawa Baru Ketapang"),
GetSetting("Mentaya Hilir Selatan"),
GetSetting("Mentaya Hilir Utara"),
GetSetting("Mentaya Hulu"),
GetSetting("Parenggean"),
GetSetting("Pulau Hanaut"),
GetSetting("Seranau"),
GetSetting("Telaga Antang"),
GetSetting("Telawang"),
GetSetting("Teluk Sampit"),
GetSetting("Tualan Hulu"),
GetSetting("Kuala Pembuang"),
GetSetting("Seruyan Hilir")
};

Console.WriteLine("");
Console.WriteLine("Sedang Menghidupkan Bot Aplikasinya ...", Console.ForegroundColor = ConsoleColor.Yellow);
Console.WriteLine("Jangan Diclose Sampai Selesai Ya Kalo Mau Beneran Ke Save", Console.ForegroundColor = ConsoleColor.Red);
Console.WriteLine("", Console.ForegroundColor = ConsoleColor.White);

driver.Navigate().GoToUrl(Links[0]);
driver.Navigate().GoToUrl(GetSetting("link0"));

for (int i = 0; i < Links.Count(); i++)
try
{
Console.WriteLine("");
Console.WriteLine("Sedang Memproses Tampilan Cuaca " + GetSetting(i.ToString()), Console.ForegroundColor = ConsoleColor.White);
for (int i = 0; i < int.Parse(GetSetting("jumlah")); i++)
{
Console.WriteLine("");
Console.WriteLine("Sedang Memproses Tampilan Halaman " + GetSetting(i.ToString()), Console.ForegroundColor = ConsoleColor.White);


driver.Navigate().GoToUrl(Links[i]);
ITakesScreenshot screenshotDriver = driver as ITakesScreenshot;

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(120));
wait.Until(ExpectedConditions.ElementIsVisible(By.TagName("img")));
Thread.Sleep(10000);
Screenshot screenshot = screenshotDriver.GetScreenshot();
screenshot.SaveAsFile(GetSetting(dir) + dir + "\\" + GetSetting(i.ToString()) + ".png");
driver.Navigate().GoToUrl(GetSetting("link" + i.ToString()));
ITakesScreenshot screenshotDriver = driver as ITakesScreenshot;

Console.WriteLine(GetSetting(i.ToString()) + " Telah Berhasil di Save");
Console.WriteLine("");
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(120));
wait.Until(ExpectedConditions.ElementIsVisible(By.TagName("img")));
Thread.Sleep(10000);

Screenshot screenshot = screenshotDriver.GetScreenshot();
screenshot.SaveAsFile(dir + "\\" + GetSetting(i.ToString()) + ".png");

Console.WriteLine(GetSetting(i.ToString()) + " Telah Berhasil di Save");
Console.WriteLine("");
}
}
catch (Exception e)
{
if(e.ToString() == "System.ArgumentNullException: Argument 'url'")
{
Console.WriteLine("");
Console.WriteLine("Screenshot Website "+ GetSetting("judul") + " Berhasil");
driver.Close();

Console.WriteLine("Screenshot Windy.com Berhasil");
LOOPING(Y);
}
}

Console.WriteLine(GetSetting("Screenshot Website "+ GetSetting("judul") + " Berhasil"));
driver.Close();

LOOPING(Y);
}

private static string GetSetting(string key)
Expand Down
Binary file modified WAS Installer.msi
Binary file not shown.

0 comments on commit 958aab6

Please sign in to comment.