Jump to content
Sign in to follow this  
luizeti

Help ER - StringRegExp

Recommended Posts

luizeti

Hello

I need to get all link (http).

takes only one link

Google Translate

Global $Gui,$busca='',$ok,$output='',$line

$Gui = GUICreate("Google", 615, 438, 195, 114)
$busca = GUICtrlCreateInput("", 18, 24, 513, 21)
$ok = GUICtrlCreateButton("OK", 538, 22, 59, 25)
$output = GUICtrlCreateEdit("", 16, 56, 585, 369)
GUICtrlSetData(-1, "")
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3
            Exit
        Case $ok
            
            Local $sData = BinaryToString( InetRead("http://www.google.com.br/search?q="&GUICtrlRead($busca)&"&start=0&sa=n"))

            $array = StringRegExp($sData, '(?i)(?s).*<ol>(.*)</ol>', 1)

;~          expression get link helps ---------------------------------------------------------------------------------------
            $arrayE = StringRegExp($array[UBound($array) - 1], '(?i)http://(.*?)"', 1)
;~          expression get link helps ---------------------------------------------------------------------------------------

            for $i = 0 to UBound($arrayE) - 1
                GUICtrlSetData($output, GUICtrlRead($output) & @CRLF & @CRLF &" "& $arrayE[$i])
            Next
            

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Malkey

Hello

I need to get all link (http).

takes only one link

....

Sounds like the wrong flag parameter.

#include <Array.au3>

Local $str = "a b c d a b c d a b c d a b c d"
Local $array = StringRegExp($str, "(a b)", 1)
_ArrayDisplay($array, "Flag = 1")

$array = StringRegExp($str, "(a b)", 2)
_ArrayDisplay($array, "Flag = 2")

$array = StringRegExp($str, "(a b)", 3)
_ArrayDisplay($array, "Flag = 3")

$array = StringRegExp($str, "(a b)", 4)
_ArrayDisplay($array, "Flag = 4  ")
For $i = 0 To UBound($array) - 1
    _ArrayDisplay($array[$i], "Flag = 4  " & "$array[" & $i & "]")
Next

You need Flag = 3, global.

Share this post


Link to post
Share on other sites
luizeti

Tranks.. :mellow:

Global $Gui,$busca='',$ok,$output='',$line

$Gui = GUICreate("Google", 615, 438, 195, 114)
$busca = GUICtrlCreateInput("", 18, 24, 513, 21)
$ok = GUICtrlCreateButton("OK", 538, 22, 59, 25)
$output = GUICtrlCreateEdit("", 16, 56, 585, 369)
GUICtrlSetData(-1, "")
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case -3
            Exit
        Case $ok
            
            Local $sData = BinaryToString( InetRead("http://www.google.com.br/search?q="&GUICtrlRead($busca)&"&start=0&sa=n"))

            $array = StringRegExp($sData, '(?i)(?s).*<ol>(.*)</ol>', 1)


        
            $arrayE = StringRegExp($array[UBound($array) - 1], '(?i)http://(.*?)"', 3)
            
            
            for $i = 0 to UBound($arrayE) - 1
                if( StringRegExp($arrayE[$i], 'google', 0) == 0 )Then
                    GUICtrlSetData($output, GUICtrlRead($output) & @CRLF &  @CRLF &" "& $arrayE[$i])
                EndIf
            
            Next
            

    EndSwitch
WEnd
Edited by luizeti

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.