Jump to content

String Manipulation and other help


 Share

Recommended Posts

Hey guys looking for some help

i am currently making a script to search http://gatherer.wizards.com/Pages/Default.aspx (it's a proof of concept at the moment)

this is what i have at the moment

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Example()

; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI
;
; See also: http://msdn.microsoft.com/workshop/brows...r/reference/objects/internetex
Func Example()
    Local $oIE, $GUIActiveX, $GUI_Input_Search, $GUI_Button_Search, $count
    Local $GUI_Button_Home, $GUI_Button_Stop, $msg, $term, $array
    
    $oIE = ObjCreate("Shell.Explorer.2")

    ; Create a simple GUI for our output
    GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    $GUIActiveX = GUICtrlCreateObj ($oIE, 10, 40, 600, 360)
    $GUI_Input_Search = GUICtrlCreateInput("", 10, 420, 100, 30)
    $GUI_Button_Search= GUICtrlCreateButton("Search", 120, 420, 100, 30)
    $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
    $GUI_Button_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)

    GUISetState()       ;Show GUI

    $oIE.navigate("http://gatherer.wizards.com/Pages/Default.aspx")

    ; Waiting for user to close the window
    While 1
        $msg = GUIGetMsg()

        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $GUI_Button_Home
                $oIE.navigate("http://gatherer.wizards.com/Pages/Default.aspx")
            Case $msg = $GUI_Input_Search
                $term = GUICtrlRead($GUI_Input_Search)
            Case $msg = $GUI_Button_Search
                $array = StringSplit($term, " ", 1)
                $count = Ubound($array) 
                MsgBox(0, "Test", "Array has " & $term)
                if $count = 1 then 
                    $oIE.navigate("http://gatherer.wizards.com/Pages/Search/Default.aspx?name=[" & $array[1] & "]"
                ElseIf $count = 2 Then
                    $oIE.navigate("http://gatherer.wizards.com/Pages/Search/Default.aspx?name=[" & $array[1] & "]+[" & $array[2] & "]")
                    Else
                    $oIE.navigate("http://gatherer.wizards.com/Pages/Search/Default.aspx?name=[" & $array[1] & "]+[" & $array[2] & "]+[" & $array[2] & "]")
                 EndIf  
        EndSelect
    WEnd

    GUIDelete()
EndFunc   ;==>Example

to search this site the URL is

http://gatherer.wizards.com/Pages/Search/Default.aspx?name=[Cardname]

but this is for one word searches for two word searches it changes to

http://gatherer.wizards.com/Pages/Search/Default.aspx?name=[firstword]+[secondword]

ok i just changed the code to work for three different situation IE one word two words or three words and i can add more if i need (if anyone has a better method of writing it let me know please)

the next step is when you do a search it redirects you to a url with an ID at the end (looks like this)

http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=212716

now i need to "rip" the ID from the URL, the image and all the information on the card

any suggestions

Edited by silurian

http://sparticus.webhop.net

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...