112 lines
4.1 KiB
C#
112 lines
4.1 KiB
C#
using OpenQA.Selenium;
|
|
using OpenQA.Selenium.Chrome;
|
|
using OpenQA.Selenium.Support.UI;
|
|
using SeleniumExtras.WaitHelpers;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
|
|
namespace DCinside_Cleaner
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
try
|
|
{
|
|
Console.Write("ID : ");
|
|
string _id = Console.ReadLine();
|
|
Console.Write("PASSWORD : ");
|
|
string _pass = Console.ReadLine();
|
|
Console.Write("글삭제 1, 댓글삭제 2 : ");
|
|
string _sel = Console.ReadLine();
|
|
|
|
if (_id == string.Empty || _pass == string.Empty || (_sel != "1" && _sel != "2"))
|
|
{
|
|
Console.Write("입력 값 잘 못 됨 !");
|
|
return;
|
|
}
|
|
|
|
ChromeOptions _ChromeOptions = new ChromeOptions();
|
|
_ChromeOptions.AddArguments("disable-infobars");
|
|
_ChromeOptions.AddArguments("--js-flags=--expose-gc");
|
|
_ChromeOptions.AddArguments("--enable-precise-memory-info");
|
|
_ChromeOptions.AddArguments("--disable-popup-blocking");
|
|
_ChromeOptions.AddArguments("--disable-default-apps");
|
|
_ChromeOptions.AddArguments("user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36");
|
|
|
|
ChromeDriverService _ChromeDriverService = ChromeDriverService.CreateDefaultService();
|
|
_ChromeDriverService.HideCommandPromptWindow = true;
|
|
|
|
ChromeDriver _ChromeDriver = new ChromeDriver(_ChromeDriverService, _ChromeOptions);
|
|
|
|
WebDriverWait _WebDriverWait = new WebDriverWait(_ChromeDriver, TimeSpan.FromSeconds(5));
|
|
|
|
_ChromeDriver.Navigate().GoToUrl(@"https://www.dcinside.com/");
|
|
|
|
string _id_path = "//*[@id=\"user_id\"]";
|
|
string _pass_path = "//*[@id=\"pw\"]";
|
|
string _login_path = "//*[@id=\"login_ok\"]";
|
|
_WebDriverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath(_id_path)));
|
|
_WebDriverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath(_pass_path)));
|
|
_WebDriverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath(_login_path)));
|
|
|
|
_ChromeDriver.FindElement(By.XPath(_id_path)).SendKeys(_id);
|
|
_ChromeDriver.FindElement(By.XPath(_pass_path)).SendKeys(_pass);
|
|
_ChromeDriver.FindElement(By.XPath(_login_path)).Click();
|
|
|
|
if (_sel == "1")
|
|
{
|
|
_ChromeDriver.Navigate().GoToUrl(@"https://gallog.dcinside.com/" + _id + "/posting?p=1");
|
|
}
|
|
else
|
|
{
|
|
_ChromeDriver.Navigate().GoToUrl(@"https://gallog.dcinside.com/" + _id + "/comment?p=1");
|
|
}
|
|
|
|
string _del_btn = "/html/body/div[1]/div[2]/main/article/div/div[3]/section/div[1]/div/ul/li[1]/div/div/button";
|
|
_WebDriverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath(_del_btn)));
|
|
|
|
while (true)
|
|
{
|
|
try
|
|
{
|
|
_ChromeDriver.FindElement(By.XPath(_del_btn)).Click();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
Thread.Sleep(100);
|
|
|
|
try
|
|
{
|
|
_ChromeDriver.SwitchTo().Alert().Accept();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
Thread.Sleep(100);
|
|
|
|
if (Console.KeyAvailable)
|
|
{
|
|
if (ConsoleKey.Escape == Console.ReadKey(true).Key)
|
|
break;
|
|
}
|
|
}
|
|
|
|
_ChromeDriver.Quit();
|
|
|
|
return;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine("ERROR : " + ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|