1. 최초커밋
This commit is contained in:
398
.gitignore
vendored
Normal file
398
.gitignore
vendored
Normal file
@@ -0,0 +1,398 @@
|
|||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/visualstudio
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio
|
||||||
|
|
||||||
|
### VisualStudio ###
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.tlog
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Nuget personal access tokens and Credentials
|
||||||
|
nuget.config
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
||||||
|
|
||||||
|
# VS Code files for those working on multiple tools
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# Local History for Visual Studio Code
|
||||||
|
.history/
|
||||||
|
|
||||||
|
# Windows Installer files from build outputs
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
### VisualStudio Patch ###
|
||||||
|
# Additional files built by Visual Studio
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/visualstudio
|
25
NaverSearcher.sln
Normal file
25
NaverSearcher.sln
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.31424.327
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NaverSearcher", "NaverSearcher\NaverSearcher.csproj", "{54262938-66CB-4A5F-926B-48C3ACDCE9CF}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{54262938-66CB-4A5F-926B-48C3ACDCE9CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{54262938-66CB-4A5F-926B-48C3ACDCE9CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{54262938-66CB-4A5F-926B-48C3ACDCE9CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{54262938-66CB-4A5F-926B-48C3ACDCE9CF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {D85D7D5D-9754-4B34-806A-EC1878B37547}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
64
NaverSearcher/Form1.Designer.cs
generated
Normal file
64
NaverSearcher/Form1.Designer.cs
generated
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
|
||||||
|
namespace NaverSearcher
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.Location = new System.Drawing.Point(562, 269);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.button1.TabIndex = 0;
|
||||||
|
this.button1.Text = "button1";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
|
this.Name = "Form1";
|
||||||
|
this.Text = "Form1";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
|
||||||
|
this.Load += new System.EventHandler(this.Form1_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
285
NaverSearcher/Form1.cs
Normal file
285
NaverSearcher/Form1.cs
Normal file
@@ -0,0 +1,285 @@
|
|||||||
|
using OpenQA.Selenium;
|
||||||
|
using OpenQA.Selenium.Chrome;
|
||||||
|
using OpenQA.Selenium.Support.UI;
|
||||||
|
using SeleniumExtras.WaitHelpers;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace NaverSearcher
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
ChromeDriver _ChromeDriver;
|
||||||
|
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
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("--headless");
|
||||||
|
_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");
|
||||||
|
|
||||||
|
// 프록시 설정
|
||||||
|
//Proxy proxy = new Proxy();
|
||||||
|
//proxy.Kind = ProxyKind.Manual;
|
||||||
|
//proxy.IsAutoDetect = false;
|
||||||
|
//proxy.HttpProxy =
|
||||||
|
//proxy.SslProxy = ip;
|
||||||
|
//_ChromeOptions.Proxy = proxy;
|
||||||
|
//_ChromeOptions.AddArgument("ignore-certificate-errors");
|
||||||
|
|
||||||
|
ChromeDriverService _ChromeDriverService = ChromeDriverService.CreateDefaultService();
|
||||||
|
_ChromeDriverService.HideCommandPromptWindow = true;
|
||||||
|
|
||||||
|
_ChromeDriver = new ChromeDriver(_ChromeDriverService, _ChromeOptions);
|
||||||
|
//_ChromeDriver = new ChromeDriver();
|
||||||
|
|
||||||
|
//_ChromeOptions.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko")
|
||||||
|
|
||||||
|
// 하루에 두번 검색
|
||||||
|
// {{바나나우유 라떼, 초코우유 라떼}, {민트초코바, 민트색}}
|
||||||
|
|
||||||
|
// 검색어 1페어
|
||||||
|
|
||||||
|
// 로그인 여부 확인
|
||||||
|
// 로그아웃 실행
|
||||||
|
// 네이버 메인
|
||||||
|
// 스크롤 내린다.
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
|
||||||
|
// 검색어 입력 (검색어 1)
|
||||||
|
// 검색어 확인
|
||||||
|
// 스크롤 내린다.
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 아무 게시글 클릭
|
||||||
|
// 이동된 페이지 작업
|
||||||
|
// 스크롤 내리기
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 새창 닫기
|
||||||
|
// 검색어 입력 (검색어 2, 기존 대기창)
|
||||||
|
// 검색어 확인
|
||||||
|
// 스크롤 내린다.
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 아무 게시글 클릭
|
||||||
|
// 이동된 페이지 작업
|
||||||
|
// 스크롤 내리기
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 새창 닫기
|
||||||
|
// 아무거나 검색 (비선형 검색어)
|
||||||
|
// 검색어 확인
|
||||||
|
// 스크롤 내린다.
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 아무 게시글 클릭
|
||||||
|
// 이동된 페이지 작업
|
||||||
|
// 스크롤 내리기
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 새창 닫기
|
||||||
|
|
||||||
|
// 검색어 2페어
|
||||||
|
|
||||||
|
// 로그인 여부 확인
|
||||||
|
// 로그아웃 실행
|
||||||
|
// 네이버 메인
|
||||||
|
// 스크롤 내린다.
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
|
||||||
|
// 검색어 입력 (검색어 1)
|
||||||
|
// 검색어 확인
|
||||||
|
// 스크롤 내린다.
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 아무 게시글 클릭
|
||||||
|
// 이동된 페이지 작업
|
||||||
|
// 스크롤 내리기
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 전부 닫기
|
||||||
|
|
||||||
|
// 로그인 여부 확인
|
||||||
|
// 로그아웃 실행
|
||||||
|
// 네이버 메인
|
||||||
|
// 스크롤 내린다.
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
|
||||||
|
// 검색어 입력 (검색어 2, 기존 대기창)
|
||||||
|
// 검색어 확인
|
||||||
|
// 스크롤 내린다.
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 아무 게시글 클릭
|
||||||
|
// 이동된 페이지 작업
|
||||||
|
// 스크롤 내리기
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 새창 닫기
|
||||||
|
// 아무거나 검색 (비선형 검색어)
|
||||||
|
// 검색어 확인
|
||||||
|
// 스크롤 내린다.
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 아무 게시글 클릭
|
||||||
|
// 이동된 페이지 작업
|
||||||
|
// 스크롤 내리기
|
||||||
|
// 20 ~ 60초 대기
|
||||||
|
// 새창 닫기
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
_ChromeDriver.execute_script('window.open("about:blank", "_blank");')
|
||||||
|
_ChromeDriver.execute_script('window.open("about:blank", "_blank");')
|
||||||
|
|
||||||
|
|
||||||
|
tabs = _ChromeDriver.window_handles
|
||||||
|
|
||||||
|
# TAB_1
|
||||||
|
_ChromeDriver.switch_to_window(tabs[0])
|
||||||
|
_ChromeDriver.get('http://www.naver.com/')
|
||||||
|
|
||||||
|
# TAB_2
|
||||||
|
_ChromeDriver.switch_to_window(tabs[1])
|
||||||
|
_ChromeDriver.get('http://www.google.com/')
|
||||||
|
*/
|
||||||
|
|
||||||
|
_ChromeDriver.Navigate().GoToUrl(@"https://naver.com");
|
||||||
|
|
||||||
|
WebDriverWait _WebDriverWait = new WebDriverWait(_ChromeDriver, TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
|
var elem = _ChromeDriver.FindElementByXPath("//*");
|
||||||
|
var source_code = elem.GetAttribute("outerHTML");
|
||||||
|
|
||||||
|
((IJavaScriptExecutor)_ChromeDriver).ExecuteScript("window.open();");
|
||||||
|
|
||||||
|
_ChromeDriver.SwitchTo().Window(_ChromeDriver.WindowHandles[1]);
|
||||||
|
|
||||||
|
string winHandleBefore = _ChromeDriver.CurrentWindowHandle;
|
||||||
|
//_ChromeDriver.SwitchTo().Window(winHandleBefore);
|
||||||
|
|
||||||
|
_WebDriverWait = new WebDriverWait(_ChromeDriver, TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
|
elem = _ChromeDriver.FindElementByXPath("//*");
|
||||||
|
source_code = elem.GetAttribute("outerHTML");
|
||||||
|
|
||||||
|
_ChromeDriver.SwitchTo().Window(_ChromeDriver.WindowHandles[1]);
|
||||||
|
|
||||||
|
winHandleBefore = _ChromeDriver.CurrentWindowHandle;
|
||||||
|
|
||||||
|
_WebDriverWait = new WebDriverWait(_ChromeDriver, TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
|
elem = _ChromeDriver.FindElementByXPath("//*");
|
||||||
|
source_code = elem.GetAttribute("outerHTML");
|
||||||
|
|
||||||
|
_ChromeDriver.Navigate().GoToUrl(@"https://inrose.com");
|
||||||
|
|
||||||
|
_WebDriverWait = new WebDriverWait(_ChromeDriver, TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
|
elem = _ChromeDriver.FindElementByXPath("//*");
|
||||||
|
source_code = elem.GetAttribute("outerHTML");
|
||||||
|
|
||||||
|
_ChromeDriver.SwitchTo().Window(_ChromeDriver.WindowHandles.First());
|
||||||
|
|
||||||
|
winHandleBefore = _ChromeDriver.CurrentWindowHandle;
|
||||||
|
|
||||||
|
_WebDriverWait = new WebDriverWait(_ChromeDriver, TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
|
elem = _ChromeDriver.FindElementByXPath("//*");
|
||||||
|
source_code = elem.GetAttribute("outerHTML");
|
||||||
|
|
||||||
|
_ChromeDriver.Navigate().GoToUrl(@"https://google.com");
|
||||||
|
|
||||||
|
_WebDriverWait = new WebDriverWait(_ChromeDriver, TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
|
elem = _ChromeDriver.FindElementByXPath("//*");
|
||||||
|
source_code = elem.GetAttribute("outerHTML");
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
_ChromeDriver.Navigate().GoToUrl(@"https://www.instagram.com/");
|
||||||
|
|
||||||
|
_WebDriverWait = new WebDriverWait(_ChromeDriver, TimeSpan.FromSeconds(3));
|
||||||
|
//_WebDriverWait.IgnoreExceptionTypes(typeof(NoSuchElementException));
|
||||||
|
|
||||||
|
string _id_xpath = "//*[@id=\"loginForm\"]/div/div[1]/div/label/input";
|
||||||
|
string _pass_xpath = "//*[@id=\"loginForm\"]/div/div[2]/div/label/input";
|
||||||
|
string _login_xpath = "//*[@id=\"loginForm\"]/div/div[3]/button/div";
|
||||||
|
|
||||||
|
_WebDriverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath(_login_xpath)));
|
||||||
|
|
||||||
|
_ChromeDriver.FindElement(By.XPath(_id_xpath)).SendKeys(@"leeumdkj@gmail.com");
|
||||||
|
_ChromeDriver.FindElement(By.XPath(_pass_xpath)).SendKeys(@"awdr1536!!");
|
||||||
|
_ChromeDriver.FindElement(By.XPath(_login_xpath)).Click();
|
||||||
|
|
||||||
|
// 알림 존재시
|
||||||
|
|
||||||
|
string _alert_xpath = "//*[@id=\"react-root\"]/section/main/div/div/div/div/button";
|
||||||
|
|
||||||
|
_WebDriverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath(_alert_xpath)));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_ChromeDriver.FindElement(By.XPath(_alert_xpath)).Click();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
_alert_xpath = "/html/body/div[4]/div/div/div/div[3]/button[2]";
|
||||||
|
|
||||||
|
_WebDriverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath(_alert_xpath)));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_ChromeDriver.FindElement(By.XPath(_alert_xpath)).Click();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
string _search_xpath = "//*[@id=\"react-root\"]/section/nav/div[2]/div/div/div[2]/input";
|
||||||
|
|
||||||
|
_WebDriverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath(_search_xpath)));
|
||||||
|
|
||||||
|
_ChromeDriver.FindElement(By.XPath(_search_xpath)).SendKeys(@"인플 검색");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
#region 인스턴스 생성 및 엑세스
|
||||||
|
|
||||||
|
string kknd = HangulString.SplitToPhonemes("ㅄ");
|
||||||
|
|
||||||
|
MessageBox.Show(kknd);
|
||||||
|
|
||||||
|
char[] arr = kknd.ToCharArray();
|
||||||
|
|
||||||
|
foreach (var item in arr)
|
||||||
|
{
|
||||||
|
Trace.WriteLine(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
_ChromeDriver.Quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
NaverSearcher/Form1.resx
Normal file
60
NaverSearcher/Form1.resx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
292
NaverSearcher/HangulChar.cs
Normal file
292
NaverSearcher/HangulChar.cs
Normal file
@@ -0,0 +1,292 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NaverSearcher
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 한글 문자 클래스: 현대 한글 문자에 대해 다양한 속성과 메서드를 제공하는 클래스입니다.
|
||||||
|
/// </summary>
|
||||||
|
public class HangulChar
|
||||||
|
{
|
||||||
|
// 한글에 대한 유니코드 범위 [44032, 55215]
|
||||||
|
private const int BeginCode = 0xAC00;
|
||||||
|
private const int EndCode = 0xD7AF;
|
||||||
|
|
||||||
|
// 문자 구성: 초성, 중성, 종성
|
||||||
|
private static readonly char[] Onset = { 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ',
|
||||||
|
'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' };
|
||||||
|
private static readonly char[] Nucleus = { 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ',
|
||||||
|
'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' };
|
||||||
|
private static readonly char[] Coda = { (char)0x00, 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ',
|
||||||
|
'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' };
|
||||||
|
|
||||||
|
// 문자 획수: 초성, 중성, 종성
|
||||||
|
private static readonly int[] OnsetStrokes = { 1, 2, 1, 2, 4, 3, 3, 4, 8, 2, 4, 1, 2, 4, 3, 2, 3, 4, 3 };
|
||||||
|
private static readonly int[] NucleusStrokes =
|
||||||
|
{ 2, 3, 3, 4, 2, 3, 3, 4, 2, 4, 5, 3, 3, 2, 4, 5, 3, 3, 1, 2, 1 };
|
||||||
|
private static readonly int[] CodaStrokes =
|
||||||
|
{ 0, 1, 2, 3, 1, 3, 4, 2, 3, 4, 6, 7, 5, 6, 7, 6, 3, 4, 6, 2, 4, 1, 2, 3, 2, 3, 4, 3 };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 문자로부터 한글 문자 클래스의 인스턴스를 생성합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="character">한글 문자(char)</param>
|
||||||
|
public HangulChar(char character)
|
||||||
|
{
|
||||||
|
this.CurrentCharacter = character;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 유니코드로부터 한글 문자 클래스의 인스턴스를 생성합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="unicode">한글 문자(char)에 해당하는 유니코드</param>
|
||||||
|
public HangulChar(int unicode)
|
||||||
|
{
|
||||||
|
this.CurrentCharacter = Convert.ToChar(unicode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 현재 인스턴스의 문자입니다.
|
||||||
|
/// </summary>
|
||||||
|
public char CurrentCharacter { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 현재 인스턴스 문자의 유니코드입니다.
|
||||||
|
/// </summary>
|
||||||
|
public int CurrentUnicode => (int)CurrentCharacter;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 인자의 음소 배열을 한글 음절로 합성합니다.
|
||||||
|
/// 반환값은 합성의 성공(가능) 여부를 나타냅니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="phonemes">초성, 중성(, 종성) 순의 한글 음소 배열</param>
|
||||||
|
/// <param name="syllable">합성된 한글 음절</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="phonemes"/>이 null로 주어질 경우</exception>
|
||||||
|
public static bool TryJoinToSyllable(char[] phonemes, out char syllable)
|
||||||
|
{
|
||||||
|
if (phonemes == null) { throw new ArgumentNullException(); }
|
||||||
|
|
||||||
|
bool isSuccess = false;
|
||||||
|
// 초성, 중성(, 종성)으로 이루어진 문자 배열인지 확인
|
||||||
|
if (phonemes.Length >= 2 && phonemes.Length <= 3)
|
||||||
|
{
|
||||||
|
bool check = Onset.Contains(phonemes[0]) && Nucleus.Contains(phonemes[1]);
|
||||||
|
isSuccess = phonemes.Length == 3 ? check && Coda.Contains(phonemes[2]) : check;
|
||||||
|
}
|
||||||
|
|
||||||
|
syllable = (char)0x00;
|
||||||
|
// 한글 음절로의 합성이 불가능한 경우
|
||||||
|
if (!isSuccess)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 한글 음절로의 합성이 가능한 경우
|
||||||
|
int onsetIndex = Array.IndexOf(Onset, phonemes[0]);
|
||||||
|
int nucleusIndex = Array.IndexOf(Nucleus, phonemes[1]);
|
||||||
|
int codaIndex = phonemes.Length == 3 ? Array.IndexOf(Coda, phonemes[2]) : 0;
|
||||||
|
int newCode = BeginCode + (onsetIndex * 588) + (nucleusIndex * 28) + codaIndex;
|
||||||
|
if (newCode < BeginCode || newCode > EndCode)
|
||||||
|
{
|
||||||
|
isSuccess = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
syllable = Convert.ToChar(newCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return isSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 인자의 음소 배열을 한글 음절로 합성합니다.
|
||||||
|
/// 합성이 불가능할 경우 예외를 발생시킵니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="phonemes">초성, 중성(, 종성) 순의 한글 음소 배열</param>
|
||||||
|
/// <exception cref="InvalidOperationException">인수의 배열이 합성 가능한 초성, 중성(, 종성)이 아닐 경우</exception>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static char JoinToSyllable(char[] phonemes)
|
||||||
|
{
|
||||||
|
bool isSuccess = TryJoinToSyllable(phonemes, out char syllable);
|
||||||
|
|
||||||
|
if (!isSuccess)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("인수의 배열은 합성 가능한 한글 초성, 중성(, 종성)이 아닙니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return syllable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 검색문자를 대상문자에 대해 (초성) 비교 후 일치 여부를 반환합니다.
|
||||||
|
/// 검색문자에 초성이 주어질 경우 초성 일치, 그렇지 않은 경우 문자 완전 일치 여부를 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchChar">(초성) 비교할 문자</param>
|
||||||
|
/// <param name="targetChar">비교 대상 문자</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsOnsetMatch(char searchChar, char targetChar)
|
||||||
|
{
|
||||||
|
// 1. 검색문자가 초성인 경우 대응하는 대상문자도 초성을 비교
|
||||||
|
// 2. 그렇지 않은 경우 대응하는 대상문자와 완전 일치 여부 비교
|
||||||
|
HangulChar shc = new HangulChar(searchChar);
|
||||||
|
HangulChar thc = new HangulChar(targetChar);
|
||||||
|
if (shc.IsOnset() && thc.TrySplitSyllable(out char[] phonemes))
|
||||||
|
{
|
||||||
|
targetChar = phonemes[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return searchChar == targetChar ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 검색문자를 현재 인스턴스의 문자에 대해 (초성) 비교 후 일치 여부를 반환합니다.
|
||||||
|
/// 검색문자에 초성이 주어질 경우 초성 일치, 그렇지 않은 경우 문자 완전 일치 여부를 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchChar">(초성) 비교할 문자</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsOnsetMatch(char searchChar)
|
||||||
|
{
|
||||||
|
return HangulChar.IsOnsetMatch(searchChar, this.CurrentCharacter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 초성으로 사용될 수 있는지 판단합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsOnset() => Onset.Contains(CurrentCharacter);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 중성으로 사용될 수 있는지 판단합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsNucleus() => Nucleus.Contains(CurrentCharacter);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 종성으로 사용될 수 있는지 판단합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsCoda() => Coda.Contains(CurrentCharacter);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 자음인지 판단합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsConsonant() => Onset.Contains(CurrentCharacter) || Coda.Contains(CurrentCharacter);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 모음인지 판단합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsVowel() => Nucleus.Contains(CurrentCharacter);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 음소(낱소리)인지 판단합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsPhoneme() => IsConsonant() || IsVowel();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 음소(낱소리)가 아닌 완전한 한글 음절인지 판단합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsSyllable() => BeginCode <= (int)CurrentCharacter && (int)CurrentCharacter <= EndCode;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 한글 문자인지 판단합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsKoreanCharacter() => IsPhoneme() || IsSyllable();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 한글 문자인지 판단합니다. (== IsKoreanCharacter())
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsHangul() => IsKoreanCharacter();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 한글 음절을 초성, 중성, 종성 순으로 분리합니다.
|
||||||
|
/// 반환 결과는 분리의 성공(가능)여부를 나타냅니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="phonemes">초성, 중성, 종성 순으로 분리된 배열</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TrySplitSyllable(out char[] phonemes)
|
||||||
|
{
|
||||||
|
// 분리 가능한 한글이 아닌 경우
|
||||||
|
if (!IsSyllable())
|
||||||
|
{
|
||||||
|
phonemes = new char[] { (char)0x00, (char)0x00, (char)0x00 };
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int foo = (int)CurrentCharacter - BeginCode;
|
||||||
|
int onsetIndex = (int)foo / 588;
|
||||||
|
int nucleusIndex = (int)(foo - onsetIndex * 588) / 28;
|
||||||
|
int codaIndex = foo - onsetIndex * 588 - 28 * nucleusIndex;
|
||||||
|
|
||||||
|
phonemes = new char[] { Onset[onsetIndex], Nucleus[nucleusIndex], Coda[codaIndex] };
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 한글 음절을 초성, 중성, 종성 순으로 분리합니다.
|
||||||
|
/// 분리가 불가능한 경우 예외를 발생시킵니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="InvalidOperationException">인스턴스의 문자가 분리 가능한 한글이 아닌 경우</exception>
|
||||||
|
/// <returns></returns>
|
||||||
|
public char[] SplitSyllable()
|
||||||
|
{
|
||||||
|
bool isSuccess = TrySplitSyllable(out char[] phonemes);
|
||||||
|
|
||||||
|
if (!isSuccess)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("인스턴스의 문자가 분리 가능한 한글이 아닙니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return phonemes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 한글 획수를 반환합니다. 한글이 아닌 문자의 경우 0을 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int CountStrokes()
|
||||||
|
{
|
||||||
|
// 한글이 아닌 경우 0을 반환
|
||||||
|
if (!IsHangul())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count;
|
||||||
|
// 한글 - 음소인 경우
|
||||||
|
if (IsPhoneme())
|
||||||
|
{
|
||||||
|
if (IsOnset())
|
||||||
|
{
|
||||||
|
count = OnsetStrokes[Array.IndexOf(Onset, CurrentCharacter)];
|
||||||
|
}
|
||||||
|
else if (IsNucleus())
|
||||||
|
{
|
||||||
|
count = NucleusStrokes[Array.IndexOf(Nucleus, CurrentCharacter)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count = CodaStrokes[Array.IndexOf(Coda, CurrentCharacter)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 한글 - 분리 가능한 음절인 경우
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ = TrySplitSyllable(out char[] phonemes);
|
||||||
|
count = OnsetStrokes[Array.IndexOf(Onset, phonemes[0])];
|
||||||
|
count += NucleusStrokes[Array.IndexOf(Nucleus, phonemes[1])];
|
||||||
|
count += CodaStrokes[Array.IndexOf(Coda, phonemes[2])];
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
390
NaverSearcher/HangulString.cs
Normal file
390
NaverSearcher/HangulString.cs
Normal file
@@ -0,0 +1,390 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NaverSearcher
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 한글 문자열 클래스: (한글을 포함한) 문자열에 대해 한글 처리에 관련된 다양한 속성과 메서드를 제공하는 클래스입니다.
|
||||||
|
/// </summary>
|
||||||
|
public class HangulString
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 문자열로부터 한글 문자열 클래스의 인스턴스를 생성합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aString">인스턴스를 생성할 문자열</param>
|
||||||
|
public HangulString(string aString) => CurrentString = aString;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 현재 인스턴스의 문자열입니다.
|
||||||
|
/// </summary>
|
||||||
|
public string CurrentString { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 문자열을 HangulChar 클래스 인스턴스의 배열로 변환하여 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException">입력 인자가 null인 경우</exception>
|
||||||
|
public static HangulChar[] ToHangulCharArray(string aString)
|
||||||
|
{
|
||||||
|
if (aString is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
return aString.ToCharArray().Select(c => new HangulChar(c)).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 문자열을 한글 문자열 부분과 나머지 문자열 부분으로 구분하여 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException">입력 인자가 null인 경우</exception>
|
||||||
|
public static string[] SeparateString(string aString)
|
||||||
|
{
|
||||||
|
if (aString is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] result = new string[2];
|
||||||
|
StringBuilder sbKorean = new StringBuilder();
|
||||||
|
StringBuilder sbOthers = new StringBuilder();
|
||||||
|
foreach (char c in aString)
|
||||||
|
{
|
||||||
|
HangulChar hc = new HangulChar(c);
|
||||||
|
if (hc.IsKoreanCharacter())
|
||||||
|
{
|
||||||
|
sbKorean.Append(c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sbOthers.Append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result[0] = sbKorean.ToString();
|
||||||
|
result[1] = sbOthers.ToString();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 문자열이 모두 한글로만 이루어져 있는지의 여부를 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsAllHangul(string aString)
|
||||||
|
{
|
||||||
|
string checkPoint = HangulString.SeparateString(aString)[1];
|
||||||
|
if (checkPoint.Length > 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 문자열에 대해 한글 음절을 초성, 중성, 종성으로 분리하여 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="aString"/>이 null인 경우</exception>
|
||||||
|
public static string SplitToPhonemes(string aString)
|
||||||
|
{
|
||||||
|
if (aString == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
foreach (char c in aString)
|
||||||
|
{
|
||||||
|
HangulChar hc = new HangulChar(c);
|
||||||
|
// 한글 음절로 판명되어 분리가 가능한 경우
|
||||||
|
if (hc.TrySplitSyllable(out char[] phonemes))
|
||||||
|
{
|
||||||
|
foreach (char pc in phonemes)
|
||||||
|
{
|
||||||
|
// 초성-중성으로만 이루어져 있는 경우 종성은 반환 문자열에 포함하지 않음
|
||||||
|
if (pc != (char)0x00)
|
||||||
|
{
|
||||||
|
sb.Append(pc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 한글 음절이 아닌 경우
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 문자열에 대해 한글 음절을 초성, 중성, 종성으로 분리하여 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="aString"/>이 null인 경우</exception>
|
||||||
|
public static string SplitToPhonemes2(string aString)
|
||||||
|
{
|
||||||
|
if (aString == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
foreach (char c in aString)
|
||||||
|
{
|
||||||
|
HangulChar hc = new HangulChar(c);
|
||||||
|
// 한글 음절로 판명되어 분리가 가능한 경우
|
||||||
|
if (hc.TrySplitSyllable(out char[] phonemes))
|
||||||
|
{
|
||||||
|
foreach (char pc in phonemes)
|
||||||
|
{
|
||||||
|
// 초성-중성으로만 이루어져 있는 경우 종성은 반환 문자열에 포함하지 않음
|
||||||
|
if (pc != (char)0x00)
|
||||||
|
{
|
||||||
|
sb.Append(pc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 한글 음절이 아닌 경우
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 여기에서 한번더 수행한다.
|
||||||
|
StringBuilder sb2 = new StringBuilder();
|
||||||
|
foreach (char c in sb.ToString())
|
||||||
|
{
|
||||||
|
HangulChar hc = new HangulChar(c);
|
||||||
|
// 한글 음절로 판명되어 분리가 가능한 경우
|
||||||
|
if (hc.TrySplitSyllable(out char[] phonemes))
|
||||||
|
{
|
||||||
|
foreach (char pc in phonemes)
|
||||||
|
{
|
||||||
|
// 초성-중성으로만 이루어져 있는 경우 종성은 반환 문자열에 포함하지 않음
|
||||||
|
if (pc != (char)0x00)
|
||||||
|
{
|
||||||
|
sb.Append(pc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 한글 음절이 아닌 경우
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb2.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 문자열 내의 초성, 중성, 종성 음소를 합성하여 반환합니다.
|
||||||
|
/// 의도하지 않은 반환 결과를 피하기 위해 일반적으로 사용하는 방식의
|
||||||
|
/// (완전한 한글 음절이 분리된) 자음/모음으로 구성된 문자열을 인수로 사용할 것을 권장합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="aString"/>이 null인 경우</exception>
|
||||||
|
public static string JoinPhonemes(string aString)
|
||||||
|
{
|
||||||
|
if (aString == null) { throw new ArgumentNullException(); }
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int curIdx = 0;
|
||||||
|
int lastIdx = aString.Length - 1;
|
||||||
|
// 마지막 인덱스 이후의 값 판단에 대한 예외를 피하기 위해 대상 문자열에 10개의 공백 임시 추가
|
||||||
|
string newString = aString + new string(' ', 10);
|
||||||
|
|
||||||
|
while (curIdx <= lastIdx)
|
||||||
|
{
|
||||||
|
// 현재 인덱스의 문자
|
||||||
|
HangulChar hc = new HangulChar(newString[curIdx]);
|
||||||
|
// 현재 인덱스의 문자가 음소가 아닌 경우 현재 문자를 더하고 다음 인덱스로 이동
|
||||||
|
if (!hc.IsPhoneme())
|
||||||
|
{
|
||||||
|
sb.Append(hc.CurrentCharacter);
|
||||||
|
curIdx++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 현재 인덱스의 문자가 음소인 경우에 대해
|
||||||
|
// (1) 현재 인덱스로부터 2글자 합성이 가능하고
|
||||||
|
// (2)-A 이후 첫 글자가 한글이 아니거나
|
||||||
|
// (2)-B 이후 두 글자(초성-중성)가 합성이 가능한 경우
|
||||||
|
// 현재 인덱스로부터 2글자를 합성하고, 인덱스를 2칸 전진
|
||||||
|
bool isCur2SpanOk = HangulChar.TryJoinToSyllable(
|
||||||
|
new char[] { newString[curIdx], newString[curIdx + 1] },
|
||||||
|
out char cur2SpanSyllable);
|
||||||
|
bool isCur2Next1Ok = !(new HangulChar(newString[curIdx + 2])).IsHangul();
|
||||||
|
bool isCur2Next2Ok = HangulChar.TryJoinToSyllable(
|
||||||
|
new char[] { newString[curIdx + 2], newString[curIdx + 3] },
|
||||||
|
out char _);
|
||||||
|
// (3) 현재 인덱스로부터 3글자 합성이 가능하고
|
||||||
|
// (4)-A 이후 첫 글자가 한글이 아니거나
|
||||||
|
// (4)-B 이후 두 글자(초성-중성)가 합성이 가능한 경우
|
||||||
|
// 현재 인덱스로부터 3글자를 합성하고, 인덱스를 3칸 전진
|
||||||
|
bool isCur3SpanOk = HangulChar.TryJoinToSyllable(
|
||||||
|
new char[] { newString[curIdx], newString[curIdx + 1], newString[curIdx + 2] },
|
||||||
|
out char cur3SpanSyllable);
|
||||||
|
bool isCur3Next1Ok = !(new HangulChar(newString[curIdx + 3])).IsHangul();
|
||||||
|
bool isCur3Next2Ok = HangulChar.TryJoinToSyllable(
|
||||||
|
new char[] { newString[curIdx + 3], newString[curIdx + 4] },
|
||||||
|
out char _);
|
||||||
|
|
||||||
|
// 상기 논리에 의한 판단부
|
||||||
|
// 2글자 기준 판단
|
||||||
|
if (isCur2SpanOk && (isCur2Next1Ok || isCur2Next2Ok))
|
||||||
|
{
|
||||||
|
sb.Append(cur2SpanSyllable);
|
||||||
|
curIdx += 2;
|
||||||
|
}
|
||||||
|
// 3글자 기준 판단
|
||||||
|
else if (isCur3SpanOk && (isCur3Next1Ok || isCur3Next2Ok))
|
||||||
|
{
|
||||||
|
sb.Append(cur3SpanSyllable);
|
||||||
|
curIdx += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append(hc.CurrentCharacter);
|
||||||
|
curIdx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 문자열에 대해 초성 검색을 실시합니다. 반환값은 초성 검색에 대한 결과의 존재여부입니다.
|
||||||
|
/// 검색 문자열에 초성이 주어질 경우 초성 일치, 그렇지 않은 경우 문자 완전 일치 여부를 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="searchString">검색할 문자열</param>
|
||||||
|
/// <param name="targetString">대상 문자열</param>
|
||||||
|
/// <param name="indices">(초성)일치가 발견된 대상 문자열 내 인덱스 배열</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"><paramref name="searchString"/> 또는 <paramref name="targetString"/>이 null인 경우</exception>
|
||||||
|
public static bool GetOnsetMatches(string searchString, string targetString, out int[] indices)
|
||||||
|
{
|
||||||
|
if (searchString == null || targetString == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<int> idxs = new List<int>();
|
||||||
|
|
||||||
|
// 검색 문자열의 길이가 대상 문자열의 길이보다 긴 경우
|
||||||
|
if (searchString.Length > targetString.Length)
|
||||||
|
{
|
||||||
|
indices = idxs.ToArray();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 대상 문자열 내의 인덱스를 증가시켜 가며
|
||||||
|
for (int curIdx = 0; curIdx < targetString.Length - searchString.Length + 1; curIdx++)
|
||||||
|
{
|
||||||
|
// 해당 인덱스로부터 검색 문자열의 길이만큼 초성일치 검색 수행
|
||||||
|
// 초성 일치가 될 경우 해당 인덱스 저장
|
||||||
|
bool isMatch = true;
|
||||||
|
for (int chkIdx = curIdx; chkIdx < curIdx + searchString.Length; chkIdx++)
|
||||||
|
{
|
||||||
|
if (!HangulChar.IsOnsetMatch(searchString[chkIdx - curIdx], targetString[chkIdx]))
|
||||||
|
{
|
||||||
|
isMatch = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isMatch)
|
||||||
|
{
|
||||||
|
idxs.Add(curIdx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
indices = idxs.ToArray();
|
||||||
|
if (indices.Length > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 현재 인스턴스의 문자열을 HangulChar 클래스 인스턴스의 배열로 변환하여 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public HangulChar[] ToHangulCharArray() => HangulString.ToHangulCharArray(CurrentString);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 현재 인스턴스의 문자열을 한글 문자열 부분과 나머지 문자열 부분으로 구분하여 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string[] SeparateString() => HangulString.SeparateString(CurrentString);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 현재 인스턴스의 문자열이 모두 한글로만 이루어져 있는지의 여부를 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsAllHangul() => HangulString.IsAllHangul(CurrentString);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 현재 인스턴스의 문자열에 대해 한글 음절을 초성, 중성, 종성으로 분리하여 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string SplitToPhonemes() => HangulString.SplitToPhonemes(CurrentString);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 인스턴스 문자열 내의 초성, 중성, 종성 음소를 합성하여 반환합니다.
|
||||||
|
/// 의도하지 않은 반환 결과를 피하기 위해 일반적으로 사용하는 방식의
|
||||||
|
/// (완전한 한글 음절이 분리된) 자음/모음으로 구성된 문자열을 인수로 사용할 것을 권장합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string JoinPhonemes() => HangulString.JoinPhonemes(CurrentString);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 인스턴스 문자열의 길이(글자수)를 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 윈도우 시스템에서는 개행문자가 2글자(2바이트)로 취급됨에 유의해야 합니다.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="ignoreWhiteSpcaes">공백문자(whitespace) 무시 여부</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int GetStringLength(bool ignoreWhiteSpcaes = false)
|
||||||
|
{
|
||||||
|
string inputString = ignoreWhiteSpcaes ? RemoveWhiteSpaces(CurrentString) : CurrentString;
|
||||||
|
return inputString.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 현재 인코딩에 대해 인스턴스 문자열의 길이(바이트)를 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 윈도우 시스템에서는 개행문자가 2글자(2바이트)로 취급됨에 유의해야 합니다.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="ignoreWhiteSpcaes">공백문자(whitespace) 무시 여부</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int GetStringByteLength(bool ignoreWhiteSpcaes = false)
|
||||||
|
{
|
||||||
|
string inputString = ignoreWhiteSpcaes ? RemoveWhiteSpaces(CurrentString) : CurrentString;
|
||||||
|
return Encoding.Default.GetByteCount(inputString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 인수의 문자열에서 공백문자(whitespace)를 제거한 문자열을 반환합니다.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="aString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string RemoveWhiteSpaces(string aString) =>
|
||||||
|
new string(aString.Where(c => !char.IsWhiteSpace(c)).Select(c => c).ToArray());
|
||||||
|
}
|
||||||
|
}
|
15
NaverSearcher/NaverSearcher.csproj
Normal file
15
NaverSearcher/NaverSearcher.csproj
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" />
|
||||||
|
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
|
||||||
|
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="92.0.4515.10700" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
23
NaverSearcher/Program.cs
Normal file
23
NaverSearcher/Program.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace NaverSearcher
|
||||||
|
{
|
||||||
|
static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
Application.Run(new Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
NaverSearcher/StringParser.cs
Normal file
10
NaverSearcher/StringParser.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NaverSearcher
|
||||||
|
{
|
||||||
|
class StringParser
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user