Reciprocal Link Checker Script

Submitted by:Pitter Alderson

Date added:29 March, 2012

Category:ASP

ASP code example to check reciprocal link

Tags: link checker

Code Snippet:

<%
'Declare variables
Dim BlnLinkBack, sReciprocalURL, sReciprocalLinkURLText
BlnLinkBack=False
sLinkBackURL="www.xentrik.net" 'this is the URL we wish to check for
sReciprocalURL= "www.xentrik.net/snippets/" 'This is the URL
'we are going to check against

If sReciprocalURL <> "" Then
'now we need to check if reciprocal link is valid and begins with http://
If Left(LCase(sReciprocalURL),7)<>"http://" Then
sReciprocalURL="http://" & sReciprocalURL
End If

On Error Resume Next
'Declare variables
Dim objXMLHTTP, sHTML
'Create an instance of the XMLHTTP object
Set objXMLHTTP = Server.CreateObject ("Microsoft.XMLHTTP")
objXMLHTTP.open "GET", sReciprocalURL, False
objXMLHTTP.send
sHTML=objXMLHTTP.statusText

If Err.number=0 OR sHTML="OK" Then
sReciprocalLinkURLText= objXMLHTTP.ResponseText
'Check if sLinkBackURL is in the text string returned
If InStr(1,sReciprocalLinkURLText, sLinkBackURL) > 0 Then
Blnlinkback=True
Else
Blnlinkback=False
End If
Else
Blnlinkback=False
End If
Set objXMLHTTP=Nothing
Else
linkback=False
End If

If Blnlinkback=False Then
response.write "No reciprocal link given. "
Else
response.write "Yes there is a reciprocal link given. "
End If
%>
 
 

Comments