Skip to content

Instantly share code, notes, and snippets.

@Patrique
Created July 29, 2013 01:14
Show Gist options
  • Save Patrique/6101583 to your computer and use it in GitHub Desktop.
Save Patrique/6101583 to your computer and use it in GitHub Desktop.
<%
FUNCTION LoadThePage(strPageText, strInputURL)
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.Open "GET", strInputURL, False
objXMLHTTP.Send
strPageText = objXMLHTTP.responseText
Set objXMLHTTP = Nothing
End FUNCTION
FUNCTION GrabTheContent(strStart, strEnd)
Dim strStartPos, strEndPos, strLength
strStartPos = 0
strEndPos = 0
strLength = 0
'Find the Start Position of the Search String
strStartPos = instr(strPageText,strStart)
'Starting from the Search String start position and call it the end position
strEndPos = instr(strStartPos, strPageText, strEnd)
'Compute the length of the string in between the start and end positions
strLength = strEndPos - strStartPos
'filter the content, use trim to eliminate leading and trailing spaces
myContent = trim(mid(strPageText,strStartPos, len(strStart))) & "<br/>" & vbCRLF
myContent = myContent & trim(mid(strPageText,strStartPos + len(strStart), StrLength - len(strStart))) & "<br/>" & vbCRLF
GrabTheContent = myContent
End FUNCTION
'Declare the string used to hold the HTTP and the start/end strings
Dim strPageText, strStart, strEnd
'Declare and initialize the string used to hold the Input Page URL
Dim strInputURL
if DateDiff("h", Application("updated"), Now()) >=1 then
strInputURL = "http://birdsinbackyards.net/species/Cacatua-roseicapilla"
'Load the desired page into a string
LoadThePage strPageText, strInputURL
strHTML = GrabTheContent("<h5>Description</h5>","<h5>Similar species</h5>")
Application.Lock
Application("content") = strHTML
Application("updated") = Now()
Application.Unlock
end if
strHTML = Application("content")
response.write (strHTML)
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment