Compare data grabbed from webpage

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
brunop
Junior Coder
Posts: 38
Joined: Mon Dec 03, 2007 2:29 pm

Compare data grabbed from webpage

Post by brunop » Sun Jun 13, 2010 2:14 pm

Im looking for a way to compare and notify me if the same data/number is found when grabbing data from a webpage.
Im using the tag extraction wizard to grab the data from a webpage, the data is called SPAN4.

I would like to be able to see a list of all the grabbed and compared data when the script ends, it does not have to be in excel but I was thinking of adding the data to an excelsheet since Im already having an excelsheet open for other uses in the script.

I already know how to grab and insert the data in an excel sheet and I am able to make excel look for doubles and turn the doubled cells red but how should I let the script look for that.

Maybe I could have excel write data in a cell when a double is found and have the script look at that cell and stop as soon as data is
entered into that specific field?

I bet there is an easier way using the script to do the work rather than rely on Excel to do it and then having the script act from that.
But how?

Bruno

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Sun Jun 13, 2010 9:07 pm

One method would be to read the data from Excel BEFORE getting the data from the webpage. Then it's a simple matter to compare the two with an IF statement.


Here is an English language (pseudo-code) version:

1.) Read cell in Excel into variable DATA1
2.) Retrieve value from Web Page and store in variable DATA2
3.) Compare variables DATA1 and DATA2 for equality


A macro script statement for step 3 might look like the following:

Code: Select all

If>DATA1=DATA2
     //The data is the same
     //Do something
Else
     //The data is NOT the same
     //Do something else
Endif

There are several threads on the forum which will show you examples for reading data from Excel. Just use the "Search" from within the forum to find them.

brunop
Junior Coder
Posts: 38
Joined: Mon Dec 03, 2007 2:29 pm

Post by brunop » Tue Jun 15, 2010 11:45 am

Hi there

Iv been reading a lot about how to import data from excel.

Would you say I should try and do it in VBScript since its already running in the script for other reasons or is it ok to mix in "DDERequest", "DBQuery" or other ways?

I found this piece of code that gets a cell value but I cannot seem to find out how to compare the grabbed data from the webpage to a row instead of just a cell. There is going to be around 40 cells in a row to compare and the number will fluctuate so I need the script to compare the whole row, is that possible?

I was hoping for a "GetRow" instead of the "GetCell" function but I have not been able to find one.

Code: Select all

'Retrieves a cell value from the specified
'worksheet
Function GetCell(Sheet,Row,Column)
  Dim xlSheet
  Set xlSheet = xlBook.Worksheets(Sheet)
  GetCell = xlSheet.Cells(Row, Column).Value
End Function

Bruno

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

concatenate Excel rows into a string to test the entire row

Post by adroege » Tue Jun 15, 2010 12:21 pm

Would you say I should try and do it in VBScript since its already running in the script for other reasons
That is what I would do.
so I need the script to compare the whole row, is that possible?
You could concatenate the cells together into one long string, then return that string back to macro scheduler. The IF condition can then test for equality between the string returned from the webpage and the string containing the row in Excel.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts