vbScript to parse raw web data

Need to develop a vbscript (can't use PowerShell) to do the following:

Open a website which shows only data, no HTML code
Parse first block of data from it

Sample URL would be 'http://sample/data'

Result would be
F|68.3|55.5|-999.9|65.8|62.6|-999.9|74.0|47.4|-999.9|71.9|48.3|-999.9

Need to extract just the value after the 'F|' and the next '|' so this would be 68.3
edrz01Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
There are two main parts to this. First is pulling in the html from the site. That is easy.  The hard part is pulling out what you need. I am going to give you some sample code I have not touched in over 10 years for an asp/vbscript page. As this is just the vbscript part, you can run it locally as a vbs. If you do that, you can't use response.write though.

It is pretty strait forward. Step 1 is to get the data.  Then step 2 is up to you to figure out how to grab just what you want and you can use various methods including regex which I am not very good at or just finding data between tags as I have done here.
   ' STEP 1 IS TO GRAB THE HTML FROM A WEB PAGE
    url = "http://some_web_site.oom/page.html" ' THE WEB PAGE YOU WANT TO PULL FROM
    
    xmlhttp.open "GET", url, false 
	xmlhttp.setRequestHeader "User-Agent","Thank you for the html"
    xmlhttp.send "" 
    
    ' AT THIS POINT YOU COULD OUTPUT THE HTML CODE YOU JUST PULLED IN WITH
    ' response.write xmlhttp.responseText
    ' OR PLACE IT IN A VARIABLE 
    ' MyVariable = xmlhttp.responseText
    
    ' STEP 2 NOW IT IS UP TO YOU TO STRIP OUT WHAT YOU DON'T WANT 
    
    
    ' ****** ONLY PULL DATA BETWEEN THE FORM TAGS **************
	txtstart= instr(1,xmlhttp.responseText, "<form>",1) 
    txtend= instr(1,xmlhttp.responseText, "</form>",1)
    
    ' ******** START TO BUILD NEW HTML ********************
	response.write("<div id=""testing"">")
	
	theHtml= mid(xmlhttp.responseText, txtstart, txtend-txtstart) ' GET THE HTML BETWEEN FORM TAGS
	
	
    theHtml=replace(theHtml,"<form>","") ' REBUILD THE FORM
	theHtml=replace(theHtml," <div class=""content"">","")
	theHtml=replace(theHtml,"bgcolor=""#0B294D""","bgcolor=""#990000""")
	theHtml=replace(theHtml,"<a href=""testing.aspx","<a target=""_blank"" href=""http://www.testing.com/pages/anotherpage.aspx")
	theHtml=replace(theHtml,"src=""Images","src=""http://www.testing.com/Images")
	
	'  STEP 3 IS TO OUTPUT THE HTML OR YOU COULD STORE IT IN YOUR DATABASE
	response.write theHtml
	response.write("</div><!-- end -->")
	
    set xmlhttp = nothing ' CLOSE IT DOWN

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.