Sign in to follow this  
Followers 0
danpaul23

stuck on problem with switch function

3 posts in this topic

I'm trying to run the script below. Basically, it looks at the price of the first book and if it is less than $5 it opens up the page for product information for that book. I will have it do some things on that page eventually but now, I'm just trying to get it to go to that page then come back to look at the next item on the page. It goes and comes back but after it has returned, it gives an error message instead of going to the next book on the page.

Thanks again.

CODE
; Script Start - Add your code below here

#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

Switch String($oSpan.className)

Case "srTitle"

$oVar4 = $oSpan.innerText

Case "otherprice"

$oVar5 = $oSpan.innerText

$oVar6 = Number(StringTrimLeft($oVar5, 1))

If $oVar6 < 5 Then

_IELinkClickByText ($oIE, $oVar4)

MsgBox(0, "", "")

_IEAction ($oIE, "back")

_IELoadWait ($oIE)

EndIf

EndSwitch

Next

EndIf

Next

EndIf

Next

Share this post


Link to post
Share on other sites



What was the error?

The error is on the Switch String line

It says:

Switch String($0Span.className)

Switch ^ERROR

Error: The requested action with this object has failed.

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