| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 한국어
- 벤치마크
- Microsoft
- 리눅스
- 프린터
- Hirano Aya
- MFC
- Firefox
- php
- youtube
- 平野綾
- Okazaki Ritsuko
- 자바스크립트
- 프로그램
- USB메모리
- 파이어폭스
- 맞춤법
- KBS
- 옥션
- KBS한국어능력시험
- 마비노기
- VMware
- xml
- vbscript
- 백업
- 윈도우즈
- 오카자키 리츠코
- gentoo
- 岡崎律子
- synology
Archives
- Today
- Total
ARCHIVE ...
구글DNS에서 유튜브 IP주소를 얻어오는 VBScript 본문
Info
- 임시파일 폴더(%temp%)에 youtube_dns.tmp라는 nslookup 쿼리를 저장합니다. youtube_dns.tmp파일은 자동으로 삭제되지 않습니다. 삭제하려면 직접 삭제하거나 임시파일 폴더를 청소하면 삭제할 수 있습니다.
- 모든 작업이 끝난 후 바탕화면에 youtube.txt파일을 생성합니다. 이 파일은 %windir%\System32\drivers\etc\hosts파일에 붙여 넣을 수 있는 형식으로 되어있습니다.
- 스크립트 실행파일의 첫줄의 strDNS를 다른 DNS서버 주소로 변경하면 그에 맞는 IP를 가져올 수 있습니다. 잘못된 주소를 넣으면 129번의 Cancel 버튼 또는 ESC키를 눌려야 할지 모릅니다.
Google Public DNS
p : 8.8.8.8 s : 8.8.4.4
Script file and contents
strDNS = "8.8.8.8"
Set objShell = WScript.CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
strTempPath = objShell.ExpandEnvironmentStrings("%temp%")
strDesktopPath = objShell.ExpandEnvironmentStrings("%UserProfile%") & "\Desktop"
If MsgBox("It takes about 5 minutes. take it easy", vbInformation + vbSystemModal + vbOkCancel) = vbCancel Then
WScript.Quit
End If
Function nslookup(strDomain)
strCmd = "%comspec% /c nslookup " & " " & strDomain & " " & strDNS & " > %temp%\youtube_dns.tmp"
objShell.Run strCmd, 0, True
Set objFile = objFS.OpenTextFile (strTempPath & "\youtube_dns.tmp", 1)
strResult = objFile.ReadAll
AddressTokens = Split(strResult, "Address:")
If UBound(AddressTokens) < 2 Then
nslookup = False
Else
AliasesTokens = Split(AddressTokens(2), "Aliases:")
strIP = Trim(AliasesTokens(0))
nslookup = strDomain & vbTab & strIP
End If
End Function
For nCache = 1 To 8
For nV = 1 To 24
strDomain = "v" & nV & ".lscache" & nCache & ".c.youtube.com"
result = True
Do
result = nslookup(strDomain)
If result = False Then
If MsgBox("Failed to get IP Address for " & strDomain & ". Try once more?", vbQuestion + vbOKCancel) = vbCancel Then
Exit Do
End If
Else
strHost = strHost & result
Exit Do
End If
Loop
Next
Next
Set newFile = objFS.CreateTextFile(strDesktopPath & "\youtube.txt", True)
newFile.Write(strHost)
newFile.Close
If MsgBox("Finished!!" & vbNewLine & "Run Explorer and Notepad?", vbQuestion + vbOkCancel) = vbOk Then
objShell.Run "%windir%\System32\drivers\etc", 1, False
objShell.Run "%UserProfile%\Desktop\youtube.txt", 1, False
End If
Reference
Comments
youtube.vbs