Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there good ASP to HTML converter? 5

Status
Not open for further replies.

EugenePaliev

Programmer
Jul 18, 2001
537
UA
Hello all!

I need some simple server component that would allow me to save some ASP page as HTML. Let's say I have a component to which I pass two parameters - 1) path to .asp page and 2) path I want HTML page to be saved.

Have anyone worked with anything like this? Or at least heard something? I found something on Microsoft's site but not sure that it's what I need (and actually didn't find how to use it).

Or maybe there is a way to accomplish what I need without any components with simple coding?

I will appreciate ANY response!!! Thanks in advance! Good Luck! :)
 
The only thing you can do is to take a "snapshot" of what your html page should look like with the data in your DB at a precise moment. If it's what you want to do, I sould try a combination of onLoad event and body.outerHTML. Water is not bad as long as it stays out human body ;-)
 
Thank you Targol!

May be I wasn't not clear enough, so... We all have asp pages, most of which change very rarely. Why to load asp page, connect to database, do some work with variables everytime? I want to create such asp page give the link not to that asp page but to some html page already created from asp page. Doing this I reduce server work and as a result site visitor gets the page faster.

I can do this by creating some string variable and than saving it to file (using FSO) but it's not the best decision, I want something simpler.

I tried to use Server.Execute but it only executes the file and doesn't let me to save its result to page... Good Luck! :)
 
You could use XMLHTTP to get the page back into a string and then save the results into the file. There are several examples floating around of using the object, you could try to search from the search tab above, you should get 4 or 5 examples (at least).

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Thank you Tarwn!

I will look for the examples and give it a try, but honestly I think that using XML parser for my needs is a bit too heavy... But anyway I very appreciate your input! Good Luck! :)
 
You can use your asp to generate the html code for the new page when it changes and then save that html output as the called page. It isn't automated, but you said that "most of which change very rarely". I'm not sure if that is what you are looking for. It seems pretty laborious though. Do the asp pages really cause that much server load? Can you make the asp pages more efficient on server resources (ie - closing open connections and clearing recordsets when you are done with them, using only one response.write statement, etc....)
-----------------------------------------------------------------
[pc] Be nice. It's only doing what you tell it to do.
mikewolf@tst-us.com
 
Thanks mike (mike? hope I'm not wrong :))!

I can make my asp pages efficient enough, but... Why to connect to database each time? Well, if you have 10-100 visitors per day it's ok, but if you want to develope such a site that can easily server thousands of visitors per day? I think reducing server and database work is efficient.

Example: take a look at the reply form at the bottom of this page, why they use image for the Your Reply title, why not to use plain text which is much more better and efficient??? Good Luck! :)
 
They use the image in "Your Reply" to make it look a little nicer than possible with plain HTML/DHTML. The server doesn't process the image - it just calls its url and sends the data stored there to your pc (I'm sure that a server can do that in nanoseconds). TekTips has thousands of hits per day and it is run using ColdFusion which can't be any easier on a server than asp (I would think that it actually requires more from the server since it can do more with less code).

"Why connect to the database each time?" The asp page only connects to the database when you ask it to. Not every asp page connects to the db. You may want to use includes to make site maintainence easier even on pages where no database info is needed. You may want to use application/session variables (which can increase server load - all those variables in memory...) -----------------------------------------------------------------
[pc] Be nice. It's only doing what you tell it to do.
mikewolf@tst-us.com
 
dwarrenp, thank you, I think this is (ASPTear component) something very similar to what I need! Good Luck! :)
 
"I think that using XML parser for my needs is a bit too heavy..."

That the beauty of misusing this object :)
The page that is requested is retrived back into the object and can then be retrieved as either an xml object or as plain text. I generally use it to borrow small pieces of other websites (like weather, headlines, etc) by just gettng the entire contents of a page and parsing for what I need. In your case this will be even easier because all you have to is write the text to a file.
Code:
<%
Response.Buffer = True
Dim objXMLHTTP, URL

' Create an xmlhttp object:
Set objXMLHTTP = Server.CreateObject(&quot;Microsoft.XMLHTTP&quot;)

URL = &quot;[URL unfurl="true"]http://www.tek-tips.com/&quot;[/URL]

' Opens the connection to the remote server.
objXMLHTTP.Open &quot;GET&quot;, URL, False

' Actually Sends the request and returns the data:
objXMLHTTP.Send

' Open a file for writing
Dim fso, f, ts
Set fso = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set f=fs.GetFile(Server.MapPath(&quot;tektips.html&quot;))
Set ts=f.OpenAsTextStream(2)    'open for write
ts.write(objXMLHTTP.ResponseText)
ts.Close
set ts=nothing
set f=nothing
set fs=nothing
%>

There you go, your own static copy of the tek-tips front page :)

This was written on the fly so it may not be perfect. Something else you may want to consider is to write this as an application that runs once an hour rather than a website. In addition you couldhave the filenames in an array and just loop through once an hour writing all of them to static files.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Tarwn thank you so much! I do VERY APPRECIATE your help (and time) that is EXACTLY what I need (even it's still a bit strange for me to use an object that is not designed for this :))! Great!
Eugene Good Luck! :)
 
Tarwn gets another star! -----------------------------------------------------------------
[pc] Be nice. It's only doing what you tell it to do.
mikewolf@tst-us.com
 
I kick the pudding out of questions :p
nunchuka.gif


But seriously, every good programmer should be ready and willing to take advantage of extra functionality that has been accidentally or purposely built into an object. In this case I think it was purposely left in for the express reason that you can't load 90% of the websites out there into an xml document because they wouldn't validate. Which would leave you with an unparseable page and no solution. Have fun with it, glad it helped :)

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top