Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

Use IE to call up a URL and search for a specific string in the response

Ok- Here goes.  Is it possible to create a vbscript that will call up a URL using "iexplore.exe www.website.com" and search the response for a string?  I ask this because I have a database engine that connects our online store with the backend DB.  This is an active page (ASP) and my server monitoring software uses WINHttp, which gets the "unsupported browser" message response.  The server monitor software supports the use of vbscripts- but I am not a programmer...
0
jcneil4
Asked:
jcneil4
  • 8
  • 7
1 Solution
 
Marv-inCommented:
1. create a asp page on your server

<--start page.asp-->
<%
var objXML = new ActiveXObject("Msxml2.XMLHTTP");
objXML.open("GET", "http://www.website.com", false);
objXML.send();
strDocument = objXML.ResponseText

strWhatYourLookingFor="this is what i want to match"

if instr(strDocument,strWhatYourLookingFor) then
  '//do what you need to
else
  '//do somthing when it doesnt match
endif
%>
<--end page.asp-->

then you can setup a scheduled task in windows to launch iexplorer http://yousite/page.asp

I will need more info on what you want to do if the string is matched or not to finish the code
0
 
jcneil4Author Commented:
Ok, this may work.  I'm not sure what I want to happen but lets start with something simple like have our asp page display "the site is running" or "the site is down".   I'll have to test it in our enviornment with my server monitor software-
Thanks for the quick response.
0
 
Marv-inCommented:
<%
var objXML = new ActiveXObject("Msxml2.XMLHTTP");
objXML.open("GET", "http://www.website.com", false);
objXML.send();
strDocument = objXML.ResponseText

strSearch="site is up" 'this string will need to be the exact text you are looking for at www.website.com

if instr(strDocument,strSearch) then
  response.write("your site is up")
else
  response.write("your site is down")
endif
%>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jcneil4Author Commented:
When I call up the page in a IE I get --HTTP 500 - Internal server error Internet Explorer--
Here is the code I am using...


<--start sitecheck.asp-->

<%
var objXML = new ActiveXObject("Msxml2.XMLHTTP");
objXML.open("GET", "http://www.mysite.com", false);
objXML.send();
strDocument = objXML.ResponseText

strSearch="Products and Services"

if instr(strDocument,strSearch) then
  response.write("your site is up")
else
  response.write("your site is down")
endif
%>

<--end sitecheck.asp-->
0
 
Marv-inCommented:
could you turn off friendly errors in IE [tools -> internet options -> advanced tab] and post the exact error you recieve.
0
 
jcneil4Author Commented:
Microsoft VBScript compilation error '800a0401'

Expected end of statement

/admin/sitecheck.asp, line 4

var objXML = new ActiveXObject("Msxml2.XMLHTTP");
------------------------------^
0
 
Marv-inCommented:
Set objXML = Server.CreateObject("MSXML2.XMLHTTP")
0
 
jcneil4Author Commented:
Microsoft VBScript compilation error '800a0414'

Cannot use parentheses when calling a Sub

/admin/sitecheck.asp, line 6

objXML.open("GET", "http://www.mysite.com", false);
--------------------------------------------------^
0
 
Marv-inCommented:
Set objXML = Server.CreateObject("MSXML2.XMLHTTP")
call objXML.open("GET", "http://www.mysite.com", false);
call objXML.send;
strDocument = objXML.ResponseText

this code should will work - i tested it this time
0
 
jcneil4Author Commented:
We are getting there...

Microsoft VBScript compilation error '800a0401'
Expected end of statement
/admin/sitecheck.asp, line 6
call objXML.open("GET", "http://www.mysite.com", false);
-------------------------------------------------------^
0
 
Marv-inCommented:
Set objXML = Server.CreateObject("MSXML2.XMLHTTP")
call objXML.open("GET", "http://www.mysite.com", false)
call objXML.send
strDocument = objXML.ResponseText

remove the semicolons - as doesnt use them - i must have java on the brain =]
0
 
jcneil4Author Commented:
we are close..
__________________________________
Microsoft VBScript compilation error '800a0400'
Expected statement
/admin/sitecheck.asp, line 17
endif
^
_____________________________________
here is what we have so far-

<--start sitecheck.asp-->
<%
Set objXML = Server.CreateObject("MSXML2.XMLHTTP")
call objXML.open("GET", "http://www.mysite.com", false)
call objXML.send
strDocument = objXML.ResponseText
strSearch="Products and Services"
if instr(strDocument,strSearch) then
  response.write("your site is up")
else
  response.write("your site is down")
endif
%>
<--end sitecheck.asp-->



0
 
Marv-inCommented:
its end if not endif
0
 
jcneil4Author Commented:
OK!  It works great.  You got your points.
0
 
Marv-inCommented:
Thanks for the grade!!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now