|
TexasWebDevelopers -> RE: Dynamic Page content (2/25/2009 9:10:17)
|
I am assuming that you want the keywords and title, etc. to change automatically without input just based on the text that is on the page. This isn't possible to do using straight server-side code. If you have the ability to install a .dll on the server that will convert the html to a text string then there are some examples floating around that might be of help. I was playing with the FSO and was able to give a path to an html page and then grab and write out several existing tags -- but that doesn't get you all the way to where you want to go. <% 'On Error Resume Next Dim geturl, title, description, keywords, strURL, con, results Dim fso, file, path 'path = "\inetpub\wwwroot\websitename\default.asp" ' FileSystemObject Set fso = CreateObject("Scripting.FileSystemObject") ' File Object Set file = fso.OpenTextFile(path, 1, False) ' Reading the contents of the File into strFileContents strFileContents = file.ReadAll ' Keywords key1 = InStr(1, strFileContents, "<meta name=""keywords"" content=""", 1) key1 = key1 + Len("<meta name=""keywords"" content=""") key2 = InStr(key1, strFileContents, """>", 1) keywords = "," & Trim(Mid(strFileContents, key1, (key2 - key1))) & "," keywords = Replace (keywords, "'", " ") ' Description desc1 = InStr(1, strFileContents, "<meta name=""description"" content=""", 1) desc1 = desc1 + Len("<meta name=""description"" content=""") desc2 = InStr(desc1, strFileContents, """>", 1) description = Trim(Mid(strFileContents, desc1, (desc2 - desc1))) description = Replace (description, "'", " ") ' Title tit1 = InStr(1, lcase(strFileContents), "<title>", 1) tit1 = tit1 + Len("<title>") tit2 = InStr(tit1, strFileContents, "</title>", 1) title = Trim(Mid(strFileContents, tit1, (tit2 - tit1))) title = Replace (title, "'", " ") response.write("title: " & title & "<br>") response.write("description: " & description & "<br>") response.write("keywords: " & keywords & "<br>") response.write("url: " & url & "<br>") response.write("mydate: " & mydate & "<br>") %>
|
|
|
|