Sign in to follow this  
Followers 0
danpaul23

making a price variant numeric?

4 posts in this topic

Still struggling with this bit of script. Trying to look at a page on Amazon get the price of a certain product and then use that price to make a decision. I can "pull" the price and display it but it doesn't seem to be stored as a numeral. When I try to do math with it, the variant seems to always have the value.

Do I need to look at the StringRegExp function?

Thanks.

CODE
#include <IE.au3>

$sURL = "http://www.amazon.com/s/ref=nb_ss_b/102-5993488-0177751?url=search-alias%3Dstripbooks&field-keywords=mystery&Go.x=0&Go.y=0&Go=Go"

$tryAttach = True

$oIE = _IECreate($sURL, $tryAttach)

$oTables = _IETableGetCollection($oIE)

For $oTable in $oTables

If String($oTable.className) = "searchresults" Then

$oTDs = _IETagnameGetCollection($oTable, "td")

For $oTD in $oTDs

If String($oTD.className) = "searchitem" Then

$oSpans = _IETagNameGetCollection($oTD, "span")

For $oSpan in $oSpans

If String($oSpan.classname) = "otherprice" Then

$oVar = $oSpan.innerText

$oVar2 = $oVar + 100

MsgBox(0, "otherprice", "price + 100: " & $oVar2)

MsgBox(0, "otherprice", "price: " & $oSpan.innerText)

EndIf

Next

EndIf

Next

EndIf

Next

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You are returning a "string" not a "number" so you have to make it one. Trim the dollar sign, make a number:

$oVar2 = '$' & Number(StringTrimLeft($oVar, 1)) + 100

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

You are returning a "string" not a "number" so you have to make it one. Trim the dollar sign, make a number:

$oVar2 = '$' & Number(StringTrimLeft($oVar, 1)) + 100
Cool, Thanks. What probably took you 10 seconds would have taken me the rest of the day.

Share this post


Link to post
Share on other sites

Cool, Thanks. What probably took you 10 seconds would have taken me the rest of the day.

It only took "10" seconds, because I've probably, in the past, waisted a day on it myself :) .

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0