Extract information from another website
How can I extract information from another website and display it on my webpage ?
And which tool offers best solution ?
# 13 Re: Extract information from another website
There are ways to get the information you want.
Try googling "screen scraping"
An example using Active Server Pages follows:
======================================================
<%
Function CurrentTemperature(iZipCode)
Dim sHTML
Dim beginpos
Dim endpos
Dim srvXmlHttp
Dim URL
CurrentTemperature = "(not available)" ' default
Set srvXmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
URL= "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=" & iZipCode
srvXmlHttp.open "GET", URL, false
srvXmlHttp.send()
If srvXmlHttp.status = 200 Then
' grab the HTML source for the entire page
sHTML = srvXmlHttp.responseText
' find code that occurs just before the current temperature
beginpos = Instr(sHTML,"<td class=""full"" id=""message2"">")
' throw away everything before this
sHTML = Mid(sHTML,beginpos,len(sHTML))
' find code that occurs just after the temperature
endpos = Instr(sHTML,"°")
' throw away everything after it
sHTML = Mid(sHTML,1,endpos)
' with what's left, find the tag just ahead of the temp
beginpos = Instr(sHTML,"<b>")
sHTML = Mid(sHTML,beginpos+3,len(sHTML))
' with what's left, find the tag just after the temp
endpos = Instr(sHTML,"</b>")
' grab the temp from between the tags and add a degree symbol
CurrentTemperature = Mid(sHTML,1,endpos-1) & "°"
End If
Set srvXMLHttp = Nothing
End Function ' CurrentTemperature
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<BODY>
<p>
<i>Currently in Houston...</i> <% =CurrentTemperature(77001) %>
</p>
</BODY>
</HTML>