Link to home
Create AccountLog in
Avatar of s_kennedy
s_kennedyFlag for Canada

asked on

How can I parse a remote website with JavaScript?

I have a heavily locked down machines on a LAN (no internet access).

I need to create some form of application that will parse a remote web page for a certain word, and display a message if it is found.

Due to the restrictions on the machine (I can't run any applications, I can't run any vbs files, etc), I believe the best option is JavaScript running through Internet Explorer 6, but I am open to other ideas.

For a real example that can be tested, I would like to be notified if http://www.google.ca contains the word "Web" (it does).

My main issue seems to be with the same origin policy, but I don't know if there's a way around that, since I only want to read the remote site, and not interact with it.
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

can you run HTA ?



<html>
<head>
<script>
function showData() {
  var html = if1.document.getElementsByTagName('html')[0].innerHTML
  document.getElementById('t1').value=html
  var webPos = html.toLowerCase().indexOf('web');
  if (webPos!=-1) alert('web found :' +html.substring(webPos-10,webPos+10))
 
}
</script>
</head>
<body>
<textarea id="t1" style="width:100%; height:5%"></textarea><br />
<iframe name="if1" style="width:100%; height:95%" src="http://www.google.ca" application="yes" onLoad="showData(this)"></iframe>
</body>
</html>

Open in new window

Avatar of s_kennedy

ASKER

You had me so excited for a minute, but I can't run hta's.
The problem is that there's no internet connection, so it needs to be running within the LAN.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thanks for your help.