- Messages
- 764
- Reaction score
- 27
- Points
- 0
Using your web site hosting server to retrieve and mashup data from other web sites is rapidly becoming an "Old School" technique. ( and of course some web hosts are making it nigh on impossible )
So there is a growing trend nowdays to move this CPU intensive work away from the central server and onto the clients PC which is typically doing very little. Android apps are a good example of this in action with mobile devices.
Sadly asking a vistor to download and run an exe file before they can view your website is unlikey to ever be a popular even with the non tech savvy at least for now anyhow.
That leaves us with only ActiveX ( XMLHTTP requests ) which only works with IE. Though vaugely remember a plugin being available for Firefox. Not as versatile as cURL but may be useful for some.
The trick of course is NOT to use the ActiveX component for every single vistor (unless the output mashup requires this) but rather to have just one visitor an hour/day/week upload the scraped data to a server side cache where all can see it regardless of browser type or security settings.
OK, schools out now go play
So there is a growing trend nowdays to move this CPU intensive work away from the central server and onto the clients PC which is typically doing very little. Android apps are a good example of this in action with mobile devices.
Sadly asking a vistor to download and run an exe file before they can view your website is unlikey to ever be a popular even with the non tech savvy at least for now anyhow.
That leaves us with only ActiveX ( XMLHTTP requests ) which only works with IE. Though vaugely remember a plugin being available for Firefox. Not as versatile as cURL but may be useful for some.
The trick of course is NOT to use the ActiveX component for every single vistor (unless the output mashup requires this) but rather to have just one visitor an hour/day/week upload the scraped data to a server side cache where all can see it regardless of browser type or security settings.
OK, schools out now go play
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<div id="stats">STANDBY - nb: this only works for IE, accept the ActiveX request. </div>
<script>
function processStateChange(){
statusDiv = document.getElementById("stats");
if (req.readyState == 0){ statusDiv.innerHTML = "WAKING UP"; }
if (req.readyState == 1){ statusDiv.innerHTML = "GETTING THERE"; }
if (req.readyState == 2){ statusDiv.innerHTML = "GOT IT!"; }
if (req.readyState == 3){ statusDiv.innerHTML = "TINKERING"; }
if (req.readyState == 4){
statusDiv.innerHTML = "ALL DONE";
var data = req.responseText; <!-- put html into javascript variable-->
<!--do something with string -->
document.write (data); <!--output data -->
}
}
req = new ActiveXObject("Msxml2.XMLHTTP");
if (req) {
req.onreadystatechange = processStateChange;
req.open("GET", "http://www.google.co.uk/search?q=car", true);
req.send();
}
</script>
</body>
</html>