2021. 1. 25. 08:23ㆍ개발/C#
먼저 코드를 작성하기 전에 Nuget을 통한 Selenium 설치 및 크롬 브라우저 버전에 맞는 chromedriver.exe를 다운로드하여, 실행파일과 동일한 경로에 위치시켜야한다.
using System;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium;
using System.Threading;
using System.IO;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("채널 주소를 입력하세요 ~!");
string result = Console.ReadLine();
Console.WriteLine("구독자 조회 프로그램을 실행합니다." + Environment.NewLine + Environment.NewLine);
IWebDriver webDriver = new ChromeDriver();
webDriver.Url = result;
//webDriver.Manage().Window.Maximize();
string result1 = webDriver.FindElement(By.Id("subscriber-count")).Text;
webDriver.Close();
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(DateTime.Now.ToShortDateString().ToString() + " 현재 " + result1);
File.WriteAllText(@"C:\Users\inwoo\Desktop\" + DateTime.Now.ToShortDateString().ToString() + " 구독자 기록.txt", result1);
}
}
}
'개발 > C#' 카테고리의 다른 글
# 일기 쓰고 텍스트 파일로 저장하는 간단한 프로그램 예제 (0) | 2021.01.25 |
---|---|
# 여러가지 프로그램을 한개 창에서 선택하여 실행시키는 프로그램 + (CMD 실행 기능) (0) | 2021.01.25 |
# 메뉴 고르기 프로그램 예제 코드 (0) | 2021.01.25 |
# 알람 시계 만들기 (0) | 2021.01.25 |
# 콘솔 창 숨기는 방법 (0) | 2021.01.25 |