그런 건 쓰레기 언어 쓰지 말고

VBScript 쓰거라.


아래 코드 메모장에 붙여넣기하고 아무이름.vbs 로 저장한 뒤 우측 메뉴 [명령 프롬프트로 열기]로 실행 ㄱㄱ


Option Explicit

On Error Resume Next

Const READYSTATE_COMPLETE = 4


Dim oIE


WScript.StdOut.Write "1. 새 창 / 2. 기존 창 : "

If CLng(Trim(WScript.StdIn.ReadLine)) = 2 Then

Dim oShell, oShlWin, oBrowser

Set oShell = WScript.CreateObject("Shell.Application")

Set oShlWin = oShell.Windows

For Each oBrowser In oShlWin

If InStr(TypeName(oBrowser.Document), "HTMLDocument") > 0 Then

If InStr(oBrowser.LocationName, "지금은맞고그때는틀리다") > 0 And InStr(LCase(oBrowser.LocationURL), "naver") > 0 Then

Set oIE = oBrowser

Exit For

End If

End If

Next

End If


If IsEmpty(oIE) Then

Set oIE = WScript.CreateObject("InternetExplorer.Application")

oIE.Visible = True

oIE.Navigate "http://search.naver.com/search.naver?where=nexearch&query=지금은맞고그때는틀리다&sm=top_sug.pre&fbm=1&acr=1&acq=지금은&qdt=0&ie=utf8"

Do Until oIE.ReadyState = READYSTATE_COMPLETE

WScript.Sleep 50

Loop

End If


Dim oElements, oSelBox, oOption

Set oElements = oIE.Document.getElementsByClassName("_theater-select_date")

Set oSelBox = oElements.Item(0)


Dim Options(), OptionsCount: OptionsCount = 0

For Each oOption In oSelBox.Options

ReDim Preserve Options(OptionsCount)

Options(OptionsCount) = (OptionsCount + 1) & ". " & oOption.Value

OptionsCount = OptionsCount + 1

Next


Dim lValue

WScript.Echo Join(Options, vbCrLf)

WScript.StdOut.Write "선택: "

lValue = CLng(Trim(WScript.StdIn.ReadLine)) - 1

If lValue < 0 Or lValue > UBound(Options) Then

WScript.Quit 1

End If


oSelBox.selectedIndex = lValue