|
Reviewing the code :
' URL
If Trim(Request.QueryString("base_url")) <> "" And _
Request.QueryString("look_for") <> "" Then
Checks to see if the base URL and absolute path entered are empty or not. Note the base URL which you
enter into 'base URL' field of Form 2 of 'addtodb.htm' page should be the base URL of your site you want to
index e.g. http://www.yoursite.com or http://www.othersite.com/yoursitefolder etc.
And the absolute path should be the absolute path to the page on your site e.g. /default.asp or /folder/anotherpage.asp etc.
So in FileSystemObject method of indexing site pages you have to enter two fields to make it work. Although only
absolute path would have been enough to index a page but when we will be displaying the results to the user, there we will
need complete path to the page so adding base URL is very important here.
strURL = Request.QueryString("base_url") & Request.QueryString("look_for")
We concatenate the given base URL and absolute path to the page to get strURL. It is this
variable which will be inserted into the database later.
path = Server.MapPath(Request.QueryString("look_for"))
path contains the mapped physical location of the given page. Note Server.MapPath
method translates the relative or absolute path of a file to a complete physical path to that file on that computer
e.g. http://127.0.0.1/folder/file.asp will be translated to c:/inetpub/wwwroot/folder/file.asp.
' FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
Creates FileSystemObject.
' File Object
Set file = fso.OpenTextFile(path, 1, False)
Using FileSystemObject's OpenTextFile method we open the given page and create that page's file
object.
' Reading the contents of the File into strFileContents
strFileContents = file.ReadAll
We then use File object's ReadAll method to read all the content of that page into the variable
strFileContents variable. Rest of the code is the same as 'addtodb.asp' page.
On the next page we create 'delfromdb.asp' to delete specific URLs from the Search Engine database if you
would later want to remove some pages from the database.
Next ->
|