|
 |
asp_web_howto thread: saving a remote html file to the local server
Message #1 by "nick" <nick@i...> on Wed, 22 Aug 2001 10:55:32
|
|
Hi all,
I need to be able to access a remote html file and save the html source as
a local file on my server. This needs to be done automatically by an asp
page or vb program periodically.
This will enable me to include news feed headlines on my site.
I have tried the following code (using FileSystemObject) but it doens't
seem to take url's as valid filenames.
'--------------------------------------------------
Dim objFSO
Dim sourcefile, destinationfile
sourcefile
= "http://www.guardian.co.uk/Distribution/Artifact_Trail_Block/0,5184,17982
1-0-5,00.html"
destinationfile = "e:/web_sites/testing.html"
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile sourcefile, destinationfile, true
'----------------------------------------------------
How can i do this?
thanks in advance,
Nick
Message #2 by "Paul R Beaulieu" <paulbeaulieu@s...> on Wed, 22 Aug 2001 07:30:23 -0400
|
|
Try using XMLHTTP object... you can fetch HTML from other sites and parse
the code to extract what you need a remove stuff that you don't want... I
use it for getting info for a Portal all the time... Paul.
-----Original Message-----
From: nick [mailto:nick@i...]
Sent: August 22, 2001 6:07 AM
To: ASP Web HowTo
Subject: [asp_web_howto] saving a remote html file to the local server
Hi all,
I need to be able to access a remote html file and save the html source as
a local file on my server. This needs to be done automatically by an asp
page or vb program periodically.
This will enable me to include news feed headlines on my site.
I have tried the following code (using FileSystemObject) but it doens't
seem to take url's as valid filenames.
'--------------------------------------------------
Dim objFSO
Dim sourcefile, destinationfile
sourcefile
= "http://www.guardian.co.uk/Distribution/Artifact_Trail_Block/0,5184,17982
1-0-5,00.html"
destinationfile = "e:/web_sites/testing.html"
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile sourcefile, destinationfile, true
'----------------------------------------------------
How can i do this?
thanks in advance,
Nick
Message #3 by "nick" <nick@i...> on Wed, 22 Aug 2001 13:22:50
|
|
Is this an asp or vb object and where can i find information / sample code
for it
thanks,
Nick
> Try using XMLHTTP object... you can fetch HTML from other sites and parse
> the code to extract what you need a remove stuff that you don't want... I
> use it for getting info for a Portal all the time... Paul.
>
> -----Original Message-----
> From: nick [mailto:nick@i...]
> Sent: August 22, 2001 6:07 AM
> To: ASP Web HowTo
> Subject: [asp_web_howto] saving a remote html file to the local server
>
>
> Hi all,
>
> I need to be able to access a remote html file and save the html source
as
> a local file on my server. This needs to be done automatically by an asp
> page or vb program periodically.
>
> This will enable me to include news feed headlines on my site.
>
> I have tried the following code (using FileSystemObject) but it doens't
> seem to take url's as valid filenames.
>
> '--------------------------------------------------
> Dim objFSO
> Dim sourcefile, destinationfile
>
> sourcefile
>
= "http://www.guardian.co.uk/Distribution/Artifact_Trail_Block/0,5184,17982
> 1-0-5,00.html"
>
> destinationfile = "e:/web_sites/testing.html"
>
> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
>
> objFSO.CopyFile sourcefile, destinationfile, true
>
> '----------------------------------------------------
>
> How can i do this?
>
> thanks in advance,
>
> Nick
Message #4 by Sam Clohesy <sam@e...> on Wed, 22 Aug 2001 17:38:46 +0100
|
|
I found this on 4guys from Rolla:
<%
Response.Buffer = True
Dim objXMLHTTP, xml
' Create an xmlhttp object:
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
' Or, for version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
' Opens the connection to the remote server.
xml.Open "GET", "http://www.yahoo.com", False
' Actually Sends the request and returns the data:
xml.Send
'Display the HTML both as HTML and as text
Response.Write "<h1>The HTML text</h1><xmp>"
Response.Write xml.responseText
Response.Write "</xmp><p><hr><p><h1>The HTML Output</h1>"
Response.Write xml.responseText
Set xml = Nothing
%>
-----Original Message-----
From: nick [mailto:nick@i...]
Sent: 22 August 2001 14:23
To: ASP Web HowTo
Subject: [asp_web_howto] RE: saving a remote html file to the local
server
Is this an asp or vb object and where can i find information / sample code
for it
thanks,
Nick
> Try using XMLHTTP object... you can fetch HTML from other sites and parse
> the code to extract what you need a remove stuff that you don't want... I
> use it for getting info for a Portal all the time... Paul.
>
> -----Original Message-----
> From: nick [mailto:nick@i...]
> Sent: August 22, 2001 6:07 AM
> To: ASP Web HowTo
> Subject: [asp_web_howto] saving a remote html file to the local server
>
>
> Hi all,
>
> I need to be able to access a remote html file and save the html source
as
> a local file on my server. This needs to be done automatically by an asp
> page or vb program periodically.
>
> This will enable me to include news feed headlines on my site.
>
> I have tried the following code (using FileSystemObject) but it doens't
> seem to take url's as valid filenames.
>
> '--------------------------------------------------
> Dim objFSO
> Dim sourcefile, destinationfile
>
> sourcefile
>
= "http://www.guardian.co.uk/Distribution/Artifact_Trail_Block/0,5184,17982
> 1-0-5,00.html"
>
> destinationfile = "e:/web_sites/testing.html"
>
> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
>
> objFSO.CopyFile sourcefile, destinationfile, true
>
> '----------------------------------------------------
>
> How can i do this?
>
> thanks in advance,
>
> Nick
Message #5 by "Paul R Beaulieu" <paulbeaulieu@s...> on Thu, 23 Aug 2001 07:53:12 -0400
|
|
That will do it, sorry I should have included an example, next time I will
be better, you can use InStr, LEft, Mid, Right functions to find certain
strings in the returned responseText, this way you can eliminate ads and any
unwanted stuff from the page, the only problem with this is if yahoo or
whoever you are getting the data from changes the page layout, but for the
most part I find they keep consistent... Paul.
-----Original Message-----
From: Sam Clohesy [mailto:sam@e...]
Sent: August 22, 2001 12:39 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: saving a remote html file to the local se
rver
I found this on 4guys from Rolla:
<%
Response.Buffer = True
Dim objXMLHTTP, xml
' Create an xmlhttp object:
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
' Or, for version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
' Opens the connection to the remote server.
xml.Open "GET", "http://www.yahoo.com", False
' Actually Sends the request and returns the data:
xml.Send
'Display the HTML both as HTML and as text
Response.Write "<h1>The HTML text</h1><xmp>"
Response.Write xml.responseText
Response.Write "</xmp><p><hr><p><h1>The HTML Output</h1>"
Response.Write xml.responseText
Set xml = Nothing
%>
-----Original Message-----
From: nick [mailto:nick@i...]
Sent: 22 August 2001 14:23
To: ASP Web HowTo
Subject: [asp_web_howto] RE: saving a remote html file to the local
server
Is this an asp or vb object and where can i find information / sample code
for it
thanks,
Nick
> Try using XMLHTTP object... you can fetch HTML from other sites and parse
> the code to extract what you need a remove stuff that you don't want... I
> use it for getting info for a Portal all the time... Paul.
>
> -----Original Message-----
> From: nick [mailto:nick@i...]
> Sent: August 22, 2001 6:07 AM
> To: ASP Web HowTo
> Subject: [asp_web_howto] saving a remote html file to the local server
>
>
> Hi all,
>
> I need to be able to access a remote html file and save the html source
as
> a local file on my server. This needs to be done automatically by an asp
> page or vb program periodically.
>
> This will enable me to include news feed headlines on my site.
>
> I have tried the following code (using FileSystemObject) but it doens't
> seem to take url's as valid filenames.
>
> '--------------------------------------------------
> Dim objFSO
> Dim sourcefile, destinationfile
>
> sourcefile
>
= "http://www.guardian.co.uk/Distribution/Artifact_Trail_Block/0,5184,17982
> 1-0-5,00.html"
>
> destinationfile = "e:/web_sites/testing.html"
>
> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
>
> objFSO.CopyFile sourcefile, destinationfile, true
>
> '----------------------------------------------------
>
> How can i do this?
>
> thanks in advance,
>
> Nick
|
|
 |