使用 vbscript 从 RSS 更新数据
Update data from RSS with vbscript
我正在编写一个 VBScript 文件 (*.vbs),它应该从此 RSS 获取数据并将它们导出到文本文件。我在互联网上搜索,但对此一无所获。
有谁知道用于创建此类功能的任何来源?
P.S。 RSS 仅显示某个日期的货币汇率。谢谢
为了让你开始,在 vbscript 你可以
- 将数据加载到
DomDocument
,因为 RSS 是 XML
Option Explicit
dim xmldoc: set xmldoc = CreateObject("MSXML2.DomDocument.6.0")
xmldoc.async = false
xmldoc.setProperty "SelectionLanguage", "XPath"
xmldoc.load "https://www.cba.am/_layouts/rssreader.aspx?rss=280F57B8-763C-4EE4-90E0-8136C13E47DA"
- 运行 使用 XPath 获取所需内容的查询
' obviously, you need to change this to your requirements
' here, we're just getting every item node
dim items: set items = xmldoc.selectNodes("//item")
- 将文本输出到文件
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim stream: set stream = fso.OpenTextFile("data.txt", 2, true)
dim item
for each item in items
' again, this changes to your requirements
' this just writes the text content of all the items and child
' nodes
stream.WriteLine item.text
next 'item
stream.Close
我正在编写一个 VBScript 文件 (*.vbs),它应该从此 RSS 获取数据并将它们导出到文本文件。我在互联网上搜索,但对此一无所获。 有谁知道用于创建此类功能的任何来源?
P.S。 RSS 仅显示某个日期的货币汇率。谢谢
为了让你开始,在 vbscript 你可以
- 将数据加载到
DomDocument
,因为 RSS 是 XML
Option Explicit
dim xmldoc: set xmldoc = CreateObject("MSXML2.DomDocument.6.0")
xmldoc.async = false
xmldoc.setProperty "SelectionLanguage", "XPath"
xmldoc.load "https://www.cba.am/_layouts/rssreader.aspx?rss=280F57B8-763C-4EE4-90E0-8136C13E47DA"
- 运行 使用 XPath 获取所需内容的查询
' obviously, you need to change this to your requirements
' here, we're just getting every item node
dim items: set items = xmldoc.selectNodes("//item")
- 将文本输出到文件
dim fso: set fso = CreateObject("Scripting.FileSystemObject")
dim stream: set stream = fso.OpenTextFile("data.txt", 2, true)
dim item
for each item in items
' again, this changes to your requirements
' this just writes the text content of all the items and child
' nodes
stream.WriteLine item.text
next 'item
stream.Close