Skip to content

Commit

Permalink
SIUUUUUU
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherzhafif committed Oct 4, 2022
1 parent 2696d8a commit f005f6a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 46 deletions.
101 changes: 55 additions & 46 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
using OpenQA.Selenium.Support.UI;
using System.Configuration;
using SeleniumExtras.WaitHelpers;
using System.ComponentModel;

namespace WebScreenshot
{
{
internal class Program
{

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

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

Expand All @@ -33,48 +32,54 @@ static void Main(String[] args)
Console.WriteLine("Jadi Anda Mau Ngescreenshot Web Apa Hari Ini ?");
Console.WriteLine("");

while (true)
{

bool loop = true;

//PIIHAN MENU

Console.WriteLine("Ketik Y untuk Screenshot Web Costume");
Console.WriteLine("Ketik W untuk Screenshot Web Windy.com Untuk Arsip BMKG");
Console.WriteLine("Ketik N Atau C Atau E untuk Keluar");
Console.WriteLine("Ketik Y untuk Screenshot Web Costume");
Console.WriteLine("Ketik W untuk Screenshot Web Windy.com Untuk Arsip BMKG");
Console.WriteLine("Ketik N Atau C Atau E untuk Keluar");

string Y = Console.ReadLine();
string Y = Console.ReadLine();

if (Y == "y" || Y == "Y")
{
CaptureCosutmeLink();
return;
}
else if (Y == "w" || Y == "W")
{
CaptureWebPage();
return;
}
else if (Y == "a")
{
return;
}
else if (Y == "n" || Y == "N" || Y == "c" || Y == "C" || Y == "e" || Y == "E")
{
Environment.Exit(0);
}
else
if (loop = true)
{
while (true)
{
return;
}
LOOPING(Y, loop);
break;
Console.WriteLine(Y);
}
}
else
{
Environment.Exit(0);
}
}


private static string GetLinks(string key)
private static bool LOOPING(string Y, bool loop)
{
return ConfigurationManager.AppSettings.Get(key);
if (Y == "y" || Y == "Y")
{
CaptureCosutmeLink();
}
else if (Y == "w" || Y == "W")
{
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;
}
return loop;
}

private static void CaptureCosutmeLink()
{
Console.WriteLine("Anda Ingin Melakukan Screenshot Lainnya ? Silahkan Masukan Nama Filenya");
Expand All @@ -90,7 +95,7 @@ private static void CaptureCosutmeLink()
options.AddArgument("--disable-gpu");
options.AddArgument("test-type");
options.AddArgument("start-maximized");
options.AddArgument("--window-size=1024,768");
options.AddArgument("--window-size=1280,720");
options.AddArgument("test-type=browser");
options.AddArgument("--ignore-certificate-errors");
options.AddArgument("--enable-precise-memory-info");
Expand All @@ -112,15 +117,14 @@ private static void CaptureCosutmeLink()
ITakesScreenshot screenshotDriver = driver as ITakesScreenshot;

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

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

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

return;
driver.Close();
}

private static void CaptureWebPage()
Expand All @@ -130,7 +134,7 @@ private static void CaptureWebPage()
options.AddArgument("--disable-gpu");
options.AddArgument("test-type");
options.AddArgument("start-maximized");
options.AddArgument("--window-size=1024,768");
options.AddArgument("--window-size=1280,720");
options.AddArgument("test-type=browser");
options.AddArgument("--ignore-certificate-errors");
options.AddArgument("--enable-precise-memory-info");
Expand Down Expand Up @@ -208,20 +212,25 @@ private static void CaptureWebPage()
wait.Until(ExpectedConditions.ElementIsVisible(By.TagName("img")));
Thread.Sleep(10000);
Screenshot screenshot = screenshotDriver.GetScreenshot();
screenshot.SaveAsFile(dir + "\\" + Names[i] + ".png");
screenshot.SaveAsFile(GetSetting(dir) + dir + "\\" + Names[i] + ".png");

Console.WriteLine(Names[i] + " Telah Berhasil di Save");
Console.WriteLine("");
}

Console.WriteLine("Screenshot Windy.com Berhasil");

return;
driver.Close();
}

private static string GetSetting(string key)
{
return ConfigurationManager.AppSettings[key];
}

private static string GetLinks(string key)
{
return ConfigurationManager.AppSettings.Get(key);
}
}

}
Binary file modified chromedriver.exe
Binary file not shown.

0 comments on commit f005f6a

Please sign in to comment.