从 URL 读取文件 [英] Read files from URL
本文介绍了从 URL 读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从 URL 读取 .css 和 .js 等文件?例如,我有一个位于 http://main/shared/css/main.css
的文件,我想读取该文件并将其内容存储在 处的另一个文件中c:\main.txt
.我知道如何读取本地驱动器中的文件,但不确定如何读取 URL.非常感谢任何帮助.
Is it possible to read files like .css and .js from a URL? For instance, I have a file, which is located at http://main/shared/css/main.css
, and want to read this file and store its content in another file at c:\main.txt
. I know how to read files in local drives but not sure how to do it for a URL. Any help is much appreciated.
推荐答案
您可以使用 XMLHttpRequest
为此:
You can use an XMLHttpRequest
for this:
url = "http://main/shared/css/main.css"
Set req = CreateObject("Msxml2.XMLHttp.6.0")
req.open "GET", url, False
req.send
If req.Status = 200 Then
Set fso = CreateObject("Scripting.FileSystemObject")
fso.OpenTextFile("C:\main.txt", 2).Write req.responseText
End If
这篇关于从 URL 读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文