안녕하세요, 저는 VBS로 RSS 피드를 구문 분석하고 내용을 cmd로 표시하는 방법을 알아 내려고합니다. 나는 그물 주변에서 발견 한 코드를 가지고있다. 이것은 내가 지금까지 얻은 것이다.VBS 스크립트를 통해 RSS 피드를 얻고 CMD에 내용을 표시하는 방법
배치 파일 :
:news
start scripts\xml\getxml.exe -N --directory-prefix=%temp% http://feeds.bbci.co.uk/news/rss.xml
:newscheck
if NOT EXIST %temp%\rss.xml (
ping 123.45.67.89 -n 1 -w 500 > nul.
goto newscheck
)
start scripts\news\parsebbcnews.vbs
ping 123.45.67.89 -n 1 -w 500 > nul.
:newsxmlparsecheck
if NOT EXIST %temp%\bbcnews.txt (
ping 123.45.67.89 -n 1 -w 500 > nul.
goto newsxmlparsecheck
)
set /p headline= <%temp%\bbcnews.txt
echo %headline%
%speech% "%headline%"
del %temp%\rss.xml
del %temp%\bbcnews.txt
goto start
다음이는 VBS를 시작합니다
는Dim xmlDoc, objNodeList, plot
Set wshShell = CreateObject("WScript.Shell")
tfolder = wshShell.ExpandEnvironmentStrings("%TEMP%")
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load(tfolder & "\rss.xml")
Set objNodeList = xmlDoc.getElementsByTagName("channel/item/description") 'Node to search for
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Write all found results into forecast.txt
Const ForWriting = 2
Set objTextFile = objFSO.OpenTextFile _
(tfolder & "\bbcnews.txt", ForWriting, True)
If objNodeList.length > 0 then
For each x in objNodeList
plot=x.Text
objTextFile.WriteLine(plot)
Next 'just remove this?
objTextFile.Close
End If
'Extract todays data (first line) from 'forecast.txt' and write each data type to seperate line in today.txt
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
(tfolder & "\bbcnews.txt", ForReading)
strNextLine = objTextFile.Readline
'currentsplit = Split(strNextLine , ", ")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(tfolder & "\headline.txt", ForWriting, True)
objTextFile.WriteLine(strNextLine)
이 영국 BBC에서 1 개 뉴스 RSS 피드를 가져옵니다. 또한 하나 이상의 피드를 표시하려고합니다.
다른 사이트에서 rss를 얻으려면 스크립트와 유사한 코드를 어떻게 얻을 수 있는지 알지 못하기 때문에이 코드를 만들지 않았습니다. 그래서 기본적으로 내가 원하는 것은 VB 스크립트로 이것을 어떻게 할 수 있고 그것을 cmd로 표시 할 수 있는지를 아는 것입니다.
안녕하세요. 감사합니다. 그것은 rss 피드에서 1 헤드 라인을 표시했습니다. 그러나 Im은 하나 이상의 피드를 어떻게 표시하는지 궁금해합니다. 지금은 각 피드에서 1 개의 헤드 라인 만 표시했습니다. 내가 표시 할 수 있도록 추가해야하는 것은 각 RSS 피드의 5 개의 피드 헤드 라인을 말합니다. 그리고 HTML 코드가 없어도 설명을 표시 할 수있는 방법이 있습니까? :) – Nivi
내 원본 답변에 이미 2 개의 피드가 있습니다. 더 많은 헤드 라인과 HTML을 제거하려면 업데이트를 참조하십시오. –
고마워요 :) 잘 했어! – Nivi