你如何从Web服务器上获取文件? [英] how do you get a file off of a web server?

查看:96
本文介绍了你如何从Web服务器上获取文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以某种方式从网址获取文件,例如:
http://www.myserver.com/data/names.txt


并在访问中使用。

我知道我可以使用Set http = CreateObject(" microsoft.xmlhttp")

来读取文件,但它可能会超过1000行。

所以如何将此输出保存到文本文件中,以便我可以将其读入

表(它是制表符分隔文件)。我知道怎么做导入,但只需要

需要帮助将这个大文本保存到文本文件中。


再次感谢

解决方案

" Danny" <哒******** @ hotmail.com>写在

新闻:U5 ******************** @ news4.srv.hcvlny.cv.ne t:
< blockquote class =post_quotes>我想以某种方式从网址获取文件,例如:
http://www.myserver.com/data/names.txt

并在访问中使用。
我知道我可以使用设置http = CreateObject(" microsoft.xmlhttp")
来读取文件,但它可能会超过1000行。
那么如何将此输出保存到文本文件中,所以然后我可以把它读成一个表(它是一个制表符分隔文件)。我知道如何导入,
但只需要帮助将这个大文本保存到文本文件中。

再次感谢




很好每个人现在几乎都使用ADO!


Public Sub GetAFile(_

ByVal URL As String,_

ByVal Destination As String,_

可选ByVal UserName As String,_

可选ByVal密码为字符串)

Dim r As ADODB.Record

设置r =新ADODB.Record

URL =" URL =" &安培;网址

目的地=" file://" &安培;目的地

带r

如果Len(用户名)> 0然后

。打开",URL ,, _

adOpenIfExists或adCreateCollection,_

,用户名,密码

Else

。打开"",URL ,, _

adOpenIfExists或adCreateCollection

结束如果

。复制记录,目的地

。关闭

结束

结束子


Sub test()

GetAFile _

" http://ffdba.com/downloads/How_Many_WeekDays.dat" ;, _

" c :/How_Many_WeekDays.dat"

End Sub


(假设它不公开,你需要登录网站。)


-

Lyle

(电子邮件参考 http://ffdba.com/


谢谢Lyle,


我不确定如何定义r变量。

我没有ADODB选项我只有
DAO。我正在使用ms access 2002.


我该怎么办?


谢谢


" ; Lyle Fairfield" <弥************ @ Invalid.Com>在消息中写道

news:Xn ******************* @ 130.133.1.4 ...

"丹尼" <哒******** @ hotmail.com>在
新闻中写道:U5 ******************** @ news4.srv.hcvlny.cv.ne t:

我想以某种方式从网址获取文件,例如:
http://www.myserver.com/data/names.txt

并在访问中使用。
我知道我可以使用Set http = CreateObject (microsoft.xmlhttp)
读取文件,但它可能会超过1000行。
那么如何将此输出保存到文本文件中,以便我可以读取它进入一个表(它是一个制表符分隔文件)。我知道如何进行导入,
但只需要帮助将这个大文本保存到文本文件中。

再次感谢



每个人都很好用ADO现在几乎所有东西!

Public Sub GetAFile(_
ByVal URL As String,_
ByVal Destination As String,_
可选ByVal UserName As String,_
可选ByVal密码为字符串)
Dim r As ADODB.Record
设置r =新ADODB.Record
URL =" URL =" &安培;网址
目的地=" file://" &安培;目的地
如果Len(用户名)> 0然后
。打开",URL ,, _
adOpenIfExists或adCreateCollection,_
,用户名,密码
等等
。打开", URL ,, _
adOpenIfExists或adCreateCollection
结束如果
。复制记录,目的地
。关闭
结束
结束子
子测试()
GetAFile _
" http://ffdba.com/downloads/How_Many_WeekDays.dat",_
" c:/How_Many_WeekDays.dat"
结束子

(您需要登录该站点,假设它不公开。)

-
Lyle
(对于e-邮件参考 http://ffdba.com/



我添加了引用,它似乎工作到了一定程度,现在我在

open语句中得到了一个

运行时错误。所有的网址和路径都是正确的。


你怎么看?


Danny


" ; Lyle Fairfield" <弥************ @ Invalid.Com>在消息中写道

news:Xn ******************* @ 130.133.1.4 ...

"丹尼" <哒******** @ hotmail.com>在
新闻中写道:U5 ******************** @ news4.srv.hcvlny.cv.ne t:

我想以某种方式从网址获取文件,例如:
http://www.myserver.com/data/names.txt

并在访问中使用。
我知道我可以使用Set http = CreateObject (microsoft.xmlhttp)
读取文件,但它可能会超过1000行。
那么如何将此输出保存到文本文件中,以便我可以读取它进入一个表(它是一个制表符分隔文件)。我知道如何进行导入,
但只需要帮助将这个大文本保存到文本文件中。

再次感谢



每个人都很好用ADO现在几乎所有东西!

Public Sub GetAFile(_
ByVal URL As String,_
ByVal Destination As String,_
可选ByVal UserName As String,_
可选ByVal密码为字符串)
Dim r As ADODB.Record
设置r =新ADODB.Record
URL =" URL =" &安培;网址
目的地=" file://" &安培;目的地
如果Len(用户名)> 0然后
。打开",URL ,, _
adOpenIfExists或adCreateCollection,_
,用户名,密码
等等
。打开", URL ,, _
adOpenIfExists或adCreateCollection
结束如果
。复制记录,目的地
。关闭
结束
结束子
子测试()
GetAFile _
" http://ffdba.com/downloads/How_Many_WeekDays.dat",_
" c:/How_Many_WeekDays.dat"
结束子

(您需要登录该站点,假设它不公开。)

-
Lyle
(对于e-邮件参考 http://ffdba.com/



I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it into a
table (it is a tab delimited file). I know how to do importing, but just
need help saving this big text to a text file.

Thanks again

解决方案

"Danny" <da********@hotmail.com> wrote in
news:U5********************@news4.srv.hcvlny.cv.ne t:

I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it
into a table (it is a tab delimited file). I know how to do importing,
but just need help saving this big text to a text file.

Thanks again



Pretty well everyone uses ADO for almost everything now!

Public Sub GetAFile( _
ByVal URL As String, _
ByVal Destination As String, _
Optional ByVal UserName As String, _
Optional ByVal Password As String)
Dim r As ADODB.Record
Set r = New ADODB.Record
URL = "URL=" & URL
Destination = "file://" & Destination
With r
If Len(UserName) > 0 Then
.Open "", URL, , _
adOpenIfExists Or adCreateCollection, _
, UserName, Password
Else
.Open "", URL, , _
adOpenIfExists Or adCreateCollection
End If
.CopyRecord , Destination
.Close
End With
End Sub

Sub test()
GetAFile _
"http://ffdba.com/downloads/How_Many_WeekDays.dat", _
"c:/How_Many_WeekDays.dat"
End Sub

(you need the login for the site assuming it''s not public.)

--
Lyle
(for e-mail refer to http://ffdba.com/)


Thanks Lyle,

I am not sure how to define the r variable.
I do not have the ADODB option I just have
DAO. I am using ms access 2002.

What can I do?

Thanks

"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...

"Danny" <da********@hotmail.com> wrote in
news:U5********************@news4.srv.hcvlny.cv.ne t:

I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it
into a table (it is a tab delimited file). I know how to do importing,
but just need help saving this big text to a text file.

Thanks again



Pretty well everyone uses ADO for almost everything now!

Public Sub GetAFile( _
ByVal URL As String, _
ByVal Destination As String, _
Optional ByVal UserName As String, _
Optional ByVal Password As String)
Dim r As ADODB.Record
Set r = New ADODB.Record
URL = "URL=" & URL
Destination = "file://" & Destination
With r
If Len(UserName) > 0 Then
.Open "", URL, , _
adOpenIfExists Or adCreateCollection, _
, UserName, Password
Else
.Open "", URL, , _
adOpenIfExists Or adCreateCollection
End If
.CopyRecord , Destination
.Close
End With
End Sub

Sub test()
GetAFile _
"http://ffdba.com/downloads/How_Many_WeekDays.dat", _
"c:/How_Many_WeekDays.dat"
End Sub

(you need the login for the site assuming it''s not public.)

--
Lyle
(for e-mail refer to http://ffdba.com/)



I added the reference and it seems to work to a point, now I am getting a
runtime error on the
open statement. All urls and paths are correct.

What do you think?

Danny

"Lyle Fairfield" <Mi************@Invalid.Com> wrote in message
news:Xn*******************@130.133.1.4...

"Danny" <da********@hotmail.com> wrote in
news:U5********************@news4.srv.hcvlny.cv.ne t:

I would like to somehow get a file from a web address such as:
http://www.myserver.com/data/names.txt

and use in access.
I know I can use the Set http = CreateObject("microsoft.xmlhttp")
to read the file, but it will be pretty big like maybe over 1000 lines.
So how would I save this output to a text file, so I can then read it
into a table (it is a tab delimited file). I know how to do importing,
but just need help saving this big text to a text file.

Thanks again



Pretty well everyone uses ADO for almost everything now!

Public Sub GetAFile( _
ByVal URL As String, _
ByVal Destination As String, _
Optional ByVal UserName As String, _
Optional ByVal Password As String)
Dim r As ADODB.Record
Set r = New ADODB.Record
URL = "URL=" & URL
Destination = "file://" & Destination
With r
If Len(UserName) > 0 Then
.Open "", URL, , _
adOpenIfExists Or adCreateCollection, _
, UserName, Password
Else
.Open "", URL, , _
adOpenIfExists Or adCreateCollection
End If
.CopyRecord , Destination
.Close
End With
End Sub

Sub test()
GetAFile _
"http://ffdba.com/downloads/How_Many_WeekDays.dat", _
"c:/How_Many_WeekDays.dat"
End Sub

(you need the login for the site assuming it''s not public.)

--
Lyle
(for e-mail refer to http://ffdba.com/)



这篇关于你如何从Web服务器上获取文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆