Ir ao conteúdo

Como implementar o search?


aristofeles

Posts recomendados

Postado

Quero a funcionalidade do Index Service, que prucura por palavras dentro de documentos, num site LOCAL (meu proprio pc é host).

No help, achei:

Using a Web page

For submitting queries by way of the World Wide Web, the Web master or administrator must create a Web page on which you can type the query. The page can be customized to help you enter and refine queries and search for various properties. The author of the page can specify particular catalogs to be searched. Results of the search are returned to you in a Web page.

como eu implemento isso????

Postado

:cool:  E ai maninho beleza????

Bom cara eu fiz uma coisa parecida com um site desenvolvido aqui no trampo.

Ex: você pega um link que vai estar enviando para o busca, com isso você terá que fazer a descrição de todas as pages suas, e elas serão exibidas na hora da conclusão da busca, a mesmo é somente interna (somente no site).

estou enviando o codigo pra você, mas é em asp. Espero te-lo ajudado em algo e a outros do forum também.                        

[]`s

Thug



<% Option Explicit %>
<%
'Set the response buffer to true
Response.Buffer = True

'Dimension global variables
Dim fsoObject   'File system object
Dim fldObject   'Folder object
Dim sarySearchWord  'Array to hold the words to be searched for
Dim strSearchWords  'Holds the search words
Dim blnIsRoot   'Set to true if we are searching in the root directory
Dim strFileURL   'Holds the path to the file on the site
Dim strServerPath  'Holds the server path to this script
Dim intNumFilesShown  'Holds the number of files shown so far
Dim intTotalFilesSearched 'Holds the number of files searched
Dim intTotalFilesFound  'Holds the total matching files found
Dim intFileNum   'Holds the file number
Dim intPageLinkLoopCounter 'Loop counter to display links to the other result pages
Dim sarySearchResults(500,2) 'Two Dimensional Array holding the search results
Dim intDisplayResultsLoopCounter 'loop counter to diplay the results of the search
Dim intResultsArrayPosition 'Stores the array position of the array storing the results
Dim blnSearchResultsFound 'Set to true if search results are found
Dim strFilesTypesToSearch 'Holds the types of files to be searched
Dim strBarredFolders  'Holds the folders that you don't want searched
Dim strBarredFiles  'Holds the names of the files not to be searched
Dim blnEnglishLanguage  'Set to True if the user is using English



'Initalise variables
intTotalFilesSearched = 0

%>
<HTML>
<HEAD>
<TITLE>busca</TITLE>
<!META content="text/html; charset=big5" http-equiv=Content-Type>
<meta name="Description" content="Outras referencias para consulta sobre a ligua e cultura chinesa">
<script type="text/javascript" language="JavaScript1.2" src="file:///I|/DEPTO%20WEB%202003/Federal%20seg/Federal/stm31.js"></script>
<LINK
><script language=JavaScript>
<!--
function sethomepage()
{
 var name = navigator.appName;
var useragent = navigator.userAgent;
var version = parseInt(navigator.appVersion);
if ( useragent.indexOf("MSIE") != -1)
{
 document.write('[url="#"]' + '<font size="2" color="#FFFFFF">????[/url]');
}
else
{
    document.write('[url="http://www.olhosvirtuais.com.br"]<font size="2" color="#FFFFFF">????[/url]');
}

}
//-->
</SCRIPT>
<META content="MSHTML 5.00.2920.0" name=GENERATOR>
<link href="file:///I|/DEPTO%20WEB%202003/Federal%20seg/Federal/main01.css" rel="stylesheet" type="text/css">

<script  language="JavaScript">
<!-- Hide from older browsers...

//Check the form before submitting
function CheckForm () {

//Check for a word to search
if (document.frmSiteSearch.search.value==""){
 alert("Please enter at least one keyword to search");
 document.frmSiteSearch.search.focus();
 return false;
}

return true
}
// -->
</script>
     
<link href="file:///I|/DEPTO%20WEB%202003/Federal%20seg/Federal/federal.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>


<BODY bgcolor="#FFFFFF" leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
<table width="760" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#175783">
 <tr>
   <td width="760" height="0" valign="top"><TABLE width=100% height=108 border=0 cellPadding=0 cellSpacing=0 bordercolor="#CCCCCC">
       <TBODY>
         <TR vAlign=center>
           <TD height="108" align=middle valign="top" bgcolor="#006699"> <div align="center">
             </div>
             <div align="right"></div></TD>
         </TR>
       </TBODY>
     </TABLE>
     <TABLE width=100% border=0 align="center" cellPadding=0 cellSpacing=0 bordercolor="#FFFFFF" bgcolor="#FFFFFF">
       <td height="4">
       <TBODY>
         <TR>
           <TD bgColor=#CCCCCC vAlign=top width=161> </TD>
           <TD width=468 align=middle  vAlign=top bgcolor="#FFFFFF"> <TABLE border=0 cellPadding=0 cellSpacing=0 width=100%>
               <TBODY>
                 <TR>
                   <TD valign="top" bgcolor="#FFFFFF"> <div align="center">
                       <div align="left"></div>
                       <div align="left"><font color="#FF0000" size="5">[b][b][img=file:///I|/DEPTO%20WEB%202003/Federal%20seg/Federal/images/tit_sis_busca.gif][/b][/b]</div>
                     </div>
                     <form method="get" name="frmSiteSearch" action="file:///I|/DEPTO%20WEB%202003/Federal%20seg/Federal/resultado.asp" onSubmit="return CheckForm();">
                       <table cellpadding="0" cellspacing="0" width="90%" align="center">
                         <tr>
                           <td height="66" width="165" align="right" rowspan="3" valign="middle"></td>
                           <td height="66" width="15" align="right" rowspan="3" valign="middle"></td>
                           <td class="arial" height="2" width="571">[b]<font color="#999999" size="2" face="Arial, Helvetica, sans-serif">
                             Procura por: [/b]</td>
                         </tr>
                         <tr>
                           <td class="normal" height="2" width="571">[b]<font color="#999999" size="2" face="Arial, Helvetica, sans-serif">
                             <input type="TEXT" name="search" maxlength="50" size="36" value="<% =Request.QueryString("Buscar") %>">
                             <input type="submit" value="Pesquisar" name="submit">
                             [/b]</td>
                         </tr>
                         <tr>
                           <td class="normal" height="2" width="571" valign="top">[b]<font color="#999999" size="2" face="Arial, Helvetica, sans-serif">
                             Seleção:

                             <input type="radio" name="mode" value="allwords" CHECKED>
                             Todas Palavras
                             <input type="radio" name="mode" value="anywords">
                             Qualquer Palavra
                             <input type="radio" name="mode" value="phrase">
                             Sentença[/b]</td>
                         </tr>
                       </table>
                     </form>
                     [b]
                     <%

'Read in all the search words into one variable
strSearchWords = Trim(Request.QueryString("search"))

'Read in all the search words into one variable
strSearchWords = Trim(Request.QueryString("search"))

'If the site is in English then use the server HTML encode method
If blnEnglishLanguage = True Then
'Replace any HTML tags with the HTML codes for the same characters (stops people entering HTML tags)
strSearchWords = Server.HTMLEncode(strSearchWords)

'If the site is not english just change the script tags
Else
'Just replace the script tag <> with HTML encoded < and >
strSearchWords = Replace(strSearchWords, "<", "<", 1, -1, 1)
strSearchWords = Replace(strSearchWords, ">", ">", 1, -1, 1)
End If

'Slit each word to be searched up and place in an array
sarySearchWord = Split(Trim(strSearchWords), " ")



'Read the file number to show from
intFileNum = CInt(Request.QueryString("FileNumPosition"))

'Set the number of files shown so far to the file number read in above
intNumFilesShown = intFileNum


'Create the file system object
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")


'If there is no words entered by the user to search for then dont carryout the file search routine
If NOT Request.QueryString("search") = "" Then


'Get the path and the root folder to be searched
Set fldObject = fsoObject.GetFolder(Server.MapPath("./"))

'Read in the server path to this ASP script
strServerPath = fldObject.Path & "\"

'Set to true as this is searching the root directory
blnIsRoot = True
 
'Call the search sub prcedure
Call SearchFile(fldObject)  

'Reset server variables
Set fsoObject = Nothing
Set fldObject = Nothing


'Call the Bubble Sort procedure to sort the results into highest matches first
Call SortResultsByNumMatches(sarySearchResults, intTotalFilesFound)
 

'Display the HTML table with the results status of the search or what type of search it is
Response.Write vbCrLf & " <table width=""98%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"" bgcolor=""#CCCCCC"">"
Response.Write vbCrLf & "    <tr>"

'Display that there where no matching records found
If blnSearchResultsFound = False Then
 Response.Write vbCrLf & "      <td>Busca no Site por [b]" & strSearchWords & "[/b]. Desculpe, nenhum resultado encontrado.</td>"  

'Else Search went OK so display how many records found
Else
 Response.Write vbCrLf & "      <td>Busca no Site por [b]" & strSearchWords & "[/b]. Resultados Encontrados " & intFileNum + 1 & " - " & intNumFilesShown & " of " & intTotalFilesFound & ".</td>"     
End If

'Close the HTML table with the search status
Response.Write vbCrLf & "   </tr>"
Response.Write vbCrLf & " </table>"
 

'HTML table to display the search results or an error if there are no results
Response.Write vbCrLf & " <table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""1"" align=""center"">"
Response.Write vbCrLf & "  <tr>"
Response.Write vbCrLf & "   <td>"  

'If no results are found then display an error message
If blnSearchResultsFound = False Then

 'Write HTML displaying the error
 Response.Write vbCrLf & "   
"
 Response.Write vbCrLf & "    Sua Pesquisa - [b]" & strSearchWords & "[/b] - não foi encontrado em qualquer arquivo deste site."
    Response.Write vbCrLf & "   

"
    Response.Write vbCrLf & "    Sugestão:"
    Response.Write vbCrLf & "   
"
    Response.Write vbCrLf & "    [list]</p><p>[*]Tenha certeza que todas as palavras foram escritas corretamente.[*]Tente palavras diferentes.[*]Tente mais palavras.[*]Tente menos palavras.[/list]"

'Else display the results
Else
 
 'Loop round to display each result within the search results array
 For intDisplayResultsLoopCounter = (intFileNum + 1) to intNumFilesShown
 
  Response.Write vbCrLf & "     
"
  Response.Write vbCrLf & "     " & sarySearchResults(intDisplayResultsLoopCounter,1)
  Response.Write vbCrLf & "     
"
 Next
End If

'Close the HTML table displaying the results
Response.Write vbCrLf & "     </td>"
Response.Write vbCrLf & "   </tr>"
Response.Write vbCrLf & " </table>"

End If


'Display an HTML table with links to the other search results
If intTotalFilesFound > intRecordsPerPage then

'Display an HTML table with links to the other search results
Response.Write vbCrLf & "
"
Response.Write vbCrLf & " <table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">"
Response.Write vbCrLf & "    <tr>"
Response.Write vbCrLf & "      <td>"
Response.Write vbCrLf & "  <table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"
Response.Write vbCrLf & "    <tr>"
Response.Write vbCrLf & "      <td width=""50%"" align=""center"">"

Response.Write vbCrLf & "  Resultados:"

 
'If the page number is higher than page 1 then display a back link    
If intNumFilesShown > intRecordsPerPage Then
 Response.Write vbCrLf & "   [url=""]<<Prev[/url] "          
End If      


'If there are more pages to display then display links to all the search results pages
If intTotalFilesFound > intRecordsPerPage Then
 
 'Loop to diplay a hyper-link to each page in the search results    
 For intPageLinkLoopCounter = 1 to CInt((intTotalFilesFound / intRecordsPerPage) + 0.5)
 
  'If the page to be linked to is the page displayed then don't make it a hyper-link
  If intFileNum = (intPageLinkLoopCounter * intRecordsPerPage) - intRecordsPerPage Then
   Response.Write vbCrLf & "       " & intPageLinkLoopCounter
  Else
 
   Response.Write vbCrLf & "       [url=""]" & intPageLinkLoopCounter & "[/url] "  
  End If
 Next
End If


'If it is Not the last of the search results than display a next link      
If intTotalFilesFound > intNumFilesShown then    
 Response.Write vbCrLf & "  [url=""]PróximosNext>>[/url]"     
End If      


'Finsh HTML the table      
Response.Write vbCrLf & "      </td>"      
Response.Write vbCrLf & "    </tr>"
Response.Write vbCrLf & "  </table>"  
Response.Write vbCrLf & "     </td>"
Response.Write vbCrLf & "   </tr>"
Response.Write vbCrLf & " </table>"


End If

%>
                     

                     [/b]
                     <div align="center">
                       <table width="98%" border="0" cellspacing="1" cellpadding="1" bgcolor="#CCCCCC" align="center">
                         <tr>
                           <td width="100%" height="3">[b]<font color="#666666" size="2" face="Arial, Helvetica, sans-serif"><font color="#006699">Pesquisado
                             <% = intTotalFilesSearched  %>
                             <font color="#006699">documento(s) no Total.
                             [/b]</td>
                           <td width="53%" align="right" height="18"></td>
                         </tr>
                       </table>
                       [b]

                       <a href="http://www.olhosvirtuais.com.br" target="_blank" class="menu_esquerdo1">Script
                       Create By OlhosVirtuais</a>[/b]</div>
                     [b]

                     [/b]</TD>
                 </TR>
               </TBODY>
             </TABLE>
             

             <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
               <tr>
                 <td> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                     <tr>
                       <td height="50">

</p>
                         <p align="center" class="texto2"></p></td>
                     </tr>
                     <tr>
                       <td>
<div align="center"></div></td>
                     </tr>
                     <tr>
                       <td height="50">

</p>
                         

</p>
                         

</p>
                         

</p>
                         

</p></td>
                     </tr>
                   </table></td>
               </tr>
             </table>
             <CENTER>
             </CENTER>
             </TD>
           <TD align=middle bgColor=#CCCCCC vAlign=top width=156><div align="right">
             </div></TD>
         </TR>
       </TBODY>
     </TABLE>
     <table width="100%" border="0" align="center" bordercolor="#FFFFFF">
       <tr>
         <td valign="top" nowrap bgcolor="#006699"><div align="center"> </div></td>
       </tr>
     </table>
     
   </td>
 </tr>
</table>
</body>
</html>
<%



'Sub procedure to do the search
Public Sub SearchFile(fldObject)

'Dimension local variabales
Dim objRegExp    'Regular Expersions object
Dim objMatches    'Holds the matches collection of the regular expresions object
Dim filObject    'File object
Dim tsObject    'Text stream object
Dim subFldObject   'Sub folder object
Dim strFileContents   'Holds the contents of the file being searched
Dim strPageTitle   'Holds the title of the page
Dim strPageDescription   'Holds the description of the page
Dim strPageKeywords   'Holds the keywords of the page
Dim intSearchLoopCounter  'Loop counter to search all the words in the array
Dim intNumMatches   'Holds the number of matches
Dim blnSearchFound   'Set to true if the search words are found

'Error handler
On Error Resume Next
 
'Loop to search each file in the folder
For Each filObject in fldObject.Files
 
   
 'Check the file extension to make sure the file is of the extension type to be searched
 If InStr(1, strFilesTypesToSearch, fsoObject.GetExtensionName(filObject.Name), vbTextCompare) > 0 Then
 
    'Check to make sure the file about to be searched is not a barred file if it is don't search the file
  If NOT InStr(1, strBarredFiles, filObject.Name, vbTextCompare) > 0 Then    
   
     'Initalise the search found variable to flase
    blnSearchFound = False
     
     'Initalise the number of matches variable
     intNumMatches = 0    
   
     'Create the regular expresions object
     Set objRegExp = New RegExp
     
     'Set the regular exprsion object to read all cases of the occurance not just the first
     objRegExp.Global = True
     
     'Set the regular expression object to ignore case
     objRegExp.IgnoreCase = True
     
           
   
     'Open the file for searching
       Set tsObject = filObject.OpenAsTextStream
 
   'Read in the contents of the file
      strFileContents = tsObject.ReadAll  
 
   'Read in the title of the file
   strPageTitle = Server.HTMLEncode(GetFileMetaTag("<title>", "</title>", strFileContents))
     
   'Read in the description meta tag of the file
   strPageDescription = Server.HTMLEncode(GetFileMetaTag("<meta name=""description"" content=""", """>", strFileContents))
   
    'Read in the keywords of the file
    strPageKeywords = Server.HTMLEncode(GetFileMetaTag("<meta name=""keywords"" content=""", """>", strFileContents))
       
   
   
    'Set the pattern using regular expressions to srip any HTML tags
    objRegExp.Pattern = "<[^>]*>"
   
    'Strip HTML tags from the contects of the file to be searched
    strFileContents = objRegExp.Replace(strFileContents,"")
     
    'Put the tittle, description and the keywords back into the file to be searched
    strFileContents = strFileContents & " " & strPageTitle & " " & strPageDescription & " " & strPageKeywords
   
   
         
    'If the user has choosen to search by phrase
    If Request.QueryString("mode") = "phrase" Then
     
     'Set the pattern to search for
     objRegExp.Pattern = "\b" & strSearchWords & "\b"
     
     'Search the file for the phrase
     Set objMatches = objRegExp.Execute(strFileContents)
     
     'Check to see if the phrase has been found
     If objMatches.Count > 0 Then
     
      'Get the number of times the phrase is matched
      intNumMatches = objMatches.Count
     
      'If the search is found then set the search found variable to true
      blnSearchFound = True
     End If
   
   
    'Else the search is either by all or any words
    Else
       
     'If the search is by all words then initialise the search found variable to true
     If Request.QueryString("mode") = "allwords" then blnSearchFound = True
     
     
     'Loop round to search for each word to be searched
     For intSearchLoopCounter = 0 to UBound(sarySearchWord)
     
      'Set the pattern to search for
      objRegExp.Pattern = "\b" & sarySearchWord(intSearchLoopCounter) & "\b"
     
      'Search the file for the search words
      Set objMatches = objRegExp.Execute(strFileContents)
          
         'Check to see if any of the words have been found
         If objMatches.Count > 0 Then
        
          'Get the number of times the search word is matched
       intNumMatches = intNumMatches + objMatches.Count
       
          'If the search word is found and the search is for any words then set the search found variable to true
          If Request.QueryString("mode") = "anywords" then blnSearchFound = True
         
         Else
          'If the search word is not found and the search is for all words then set the search found variable back to false as one of the words has not been found
          If Request.QueryString("mode") = "allwords" then blnSearchFound = False
         
         End If
        Next
       End If
              
      
       'Calculate the total files searched
       intTotalFilesSearched = intTotalFilesSearched + 1
 
 
      
       'If the page contains no title then Page Title variable the appropriate message to display
       If strPageTitle = "" Then strPageTitle = "Sem Titulo"
      
       'If the page contains no title then Page Description variable the appropriate message to display
       If strPageDescription = "" Then strPageDescription = "Não há descrição disponivel para esta página"
      
                           
      
       'If the search found variable is true then display the results
       If blnSearchFound = True Then
             
                     
    'Calculate the total files found
    intTotalFilesFound = intTotalFilesFound + 1
         
               
    'Check that the file shown is between the the files shown so far and the maximum files to show per page
    If  intNumFilesShown < (intRecordsPerPage + intFileNum) and intTotalFilesFound > intNumFilesShown Then

     'Calculate the number of results shown
     intNumFilesShown = intNumFilesShown + 1
     
    End If
 
            
           
           'Place the search results into the saerch results array
           'Calculate the array position of the results array
           intResultsArrayPosition = intResultsArrayPosition + 1
          
           
           'Set the search results found boolean to true
           blnSearchResultsFound = True
                       
    'If the file is in the root directory then
    If blnIsRoot = True Then
     
     
     'Place the search results into the search results array
     sarySearchResults(intResultsArrayPosition,1) = "[url=""]" & strPageTitle & "[/url]"
           
                         
           'Else it is not in the root directiory
           Else
            'Place the search results into the search results array
            sarySearchResults(intResultsArrayPosition,1) = "[url=""]" & strPageTitle & "[/url]"                   
     
    End If      
   
    'Place the rest of the search results in the search results array
    sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & vbCrLf & "        
" & strPageDescription
    sarySearchResults(intResultsArrayPosition,1) = sarySearchResults(intResultsArrayPosition,1) & vbCrLf & "        <font size=""2"" color=""#0000FF"">
[i]Encontrado " & intNumMatches & " Ocorrência(s)" & " - Ultima Atualização " & FormatDateTime(filObject.DateLastModified, VbLongDate) & " - Tamanho " & CInt(filObject.Size / 1024) & "kb[/i]"
   
   
   
    'Read in the number of search word matches into the second part of the two dimensional array
    sarySearchResults(intResultsArrayPosition,2) = intNumMatches
       
         End If
   
   'Reset the Regular Expression object
   Set objRegExp = Nothing
     
   'Close the text stream object
       tsObject.Close
  End If
 End If
Next
 

'Loop to search through the sub folders within the site
For Each subFldObject In FldObject.SubFolders
         
 'Check to make sure the folder about to be searched is not a barred folder if it is then don't search
 If NOT InStr(1, strBarredFolders, subFldObject.Name, vbTextCompare) > 0 Then
 
  'Set to false as we are searching sub directories
  blnIsRoot = False
     
   
  'Get the server path to the file
  strFileURL = fldObject.Path & "\"
 
  'Turn the server path to the file into a URL path to the file
  strFileURL = Replace(strFileURL, strServerPath, "")
 
  'Replace the NT backslash with the internet forward slash in the URL to the file
  strFileURL = Replace(strFileURL, "\", "/")
 
  'Replace the spaces in the URL to the file with Internet friendly %20
  strFileURL = Replace(strFileURL, " ", "%20")
 
     
  'Call the search sub prcedure to search the web site
  Call SearchFile(subFldObject)
 End If
Next



'Reset server variables
Set filObject = Nothing
Set tsObject = Nothing
Set subFldObject = Nothing
End Sub




'Sub procedure to sort the array using a Bubble Sort to place highest matches first
Private Sub SortResultsByNumMatches(ByRef sarySearchResults, ByRef intTotalFilesFound)

'Dimension variables
Dim intArrayGap   'Holds the part of the array being sorted
Dim intIndexPosition  'Holds the Array index position being sorted
Dim intTempResultsHold  'Temperary hold for the results if they need swapping array positions  
Dim intTempNumMatchesHold 'Temperary hold for the number of matches for the result if they need swapping array positions
Dim intPassNumber  'Holds the pass number for the sort


'Loop round to sort each result found
For intPassNumber = 1 To intTotalFilesFound

 'Shortens the number of passes
 For intIndexPosition = 1 To (intTotalFilesFound - intPassNumber)
 
  'If the Result being sorted hass less matches than the next result in the array then swap them
  If sarySearchResults(intIndexPosition,2) < sarySearchResults((intIndexPosition+1),2) Then
 
   
   'Place the Result being sorted in a temporary variable
   intTempResultsHold = sarySearchResults(intIndexPosition,1)
   
   'Place the Number of Matches for the result being sorted in a temporary variable
   intTempNumMatchesHold = sarySearchResults(intIndexPosition,2)
   
   
   'Do the array position swap
   
   'Move the next Result with a higher match rate into the present array location
   sarySearchResults(intIndexPosition,1) = sarySearchResults((intIndexPosition+1),1)
       
   'Move the next Number of Matches for the result with a higher match rate into the present array location
   sarySearchResults(intIndexPosition,2) = sarySearchResults((intIndexPosition+1),2)
   
   'Move the Result from the teporary holding variable into the next array position
   sarySearchResults((intIndexPosition+1),1) = intTempResultsHold
   
   'Move the Number of Matches for the result from the teporary holding variable into the next array position
   sarySearchResults((intIndexPosition+1),2) = intTempNumMatchesHold  
  End If
 Next  
Next    
End Sub




'Function to read in the files meta tags
Private Function GetFileMetaTag(ByRef strStartValue, ByRef strEndValue, ByVal strFileContents)

'Dimension Variables
Dim intStartPositionInFile 'Holds the start position in the file
Dim intEndPositionInFile 'Holds the end position in the file


'Get the start position in the file of the meta tag
intStartPositionInFile = InStr(1, LCase(strFileContents), strStartValue, 1)


'If no description or keywords are found then you may be using http-equiv= instead of name= in your meta tags
If intStartPositionInFile = 0 And InStr(strStartValue, "name=") Then
 
 'Swap name= for http-equiv=
 strStartValue = Replace(strStartValue, "name=", "http-equiv=")
 
 'Check again for keywords or description
 intStartPositionInFile = InStr(1, LCase(strFileContents), strStartValue, 1)  
End If

       
'If there is a description then the position in file will be over 0
If NOT intStartPositionInFile = 0 Then
   
 'Get the end position of the HTML meta tag
 intStartPositionInFile = intStartPositionInFile + Len(strStartValue)
     
 'Get the position in file of the closing tag for the meta tag
 intEndPositionInFile = InStr(intStartPositionInFile, LCase(strFileContents), strEndValue, 1)

 'Read in the meta tag from the file for the function to return
 GetFileMetaTag = Trim(Mid(strFileContents, intStartPositionInFile, (intEndPositionInFile - intStartPositionInFile)))
   
'If the is no meta tag then the GetFileMetaTag function returns a null value
Else
 GetFileMetaTag = ""
         
End If

End Function
%>
 

Postado

Quaquer coisa se for posto em um site me avise para que eu possa acessar e de repente puder ajudalo em algo!

Thug

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

LANÇAMENTO!

eletronica2025-popup.jpg


CLIQUE AQUI E BAIXE AGORA MESMO!