Jump to content

Recommended Posts

Posted (edited)

Hello, I need subdomains
But there is no response in GUICtrlSetData($Edit2, $aSubdomain[$i] & @CRLF, 1)

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

Global $aListUrl = "https://www.autoitscript.com/forum/" & @crlf & _
'https://www.autoitscript.com' & @crlf & _
'https://test.blogspot.com.tr' & @crlf & _
'https://test.blogspot.com' & @crlf & _
'http://test.blogspot.com.tr' & @crlf & _
'http://test.blogspot.com' & @crlf & _
'test.blogspot.com.tr'

$Form1 = GUICreate("Form1", 830, 668)
$Edit1 = GUICtrlCreateEdit("", 32, 48, 353, 545)
GUICtrlSetData($Edit1, $aListUrl)
GUICtrlSetLimit($Edit1, 90000000)
$Edit2 = GUICtrlCreateEdit("" & @CRLF, 400, 48, 401, 553, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
GUICtrlSetLimit($Edit2, 90000000)
$ExtractSubDomain = GUICtrlCreateButton("Extract", 32, 616, 75, 25)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $ExtractSubDomain
$TestString = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF, 2)
$aSubdomain = StringRegExp($TestString, 'https?:\/\/[\w+\.]+[blogspot.com][blogspot.com.tr]', 3)
For $i = 0 To UBound($aSubdomain) - 1
GUICtrlSetData($Edit2, $aSubdomain[$i] & @CRLF, 1)
Next
    EndSwitch
WEnd

 

Edited by youtuber
Posted

youtuber,

This is what I think you are trying to do.  Note sub domain is the 1st node after protocol.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>

Global $aListUrl = "https://www.autoitscript.com/forum/" & @CRLF & _
        'https://www.autoitscript.com' & @CRLF & _
        'https://test.blogspot.com.tr' & @CRLF & _
        'https://test.blogspot.com' & @CRLF & _
        'http://test.blogspot.com.tr' & @CRLF & _
        'http://test.blogspot.com' & @CRLF & _
        'test.blogspot.com.tr'

$Form1 = GUICreate("Form1", 830, 668)
$Edit1 = GUICtrlCreateEdit("", 32, 48, 353, 545)
GUICtrlSetData($Edit1, $aListUrl)
GUICtrlSetLimit($Edit1, 90000000)
$Edit2 = GUICtrlCreateEdit("" & @CRLF, 400, 48, 401, 553, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
GUICtrlSetLimit($Edit2, 90000000)
$ExtractSubDomain = GUICtrlCreateButton("Extract", 32, 616, 75, 25, $BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW)
ControlFocus('', '', $ExtractSubDomain)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

            ; this works and follows the technique you were using

;~      Case $ExtractSubDomain
;~          $TestString = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF, 2)
;~          ;_ArrayDisplay($TestString)
;~          For $i = 0 To UBound($TestString) - 1
;~              $sSubdomain = StringRegExp($TestString[$i], '(?:https?:\/\/)?(.*?)\.', 3)
;~              If Not @error Then GUICtrlSetData($Edit2, $sSubdomain[0] & @CRLF, 1)
;~          Next

            ; This is a cleaner, more efficient way

        Case $ExtractSubDomain
            $aSubdomain = StringRegExp($aListUrl, '(?im)^(?:https?:\/\/)?(.*?)\.', 3)
            For $i = 0 To UBound($aSubdomain) - 1
                GUICtrlSetData($Edit2, $aSubdomain[$i] & @CRLF, 1)
            Next

    EndSwitch
WEnd

  I corrected several mistakes in your code, most notably, trying to reference an array as a simple variable (no index)

$aSubdomain = StringRegExp($TestString, 'https?:\/\/[\w+\.]+[blogspot.com][blogspot.com.tr]', 3)

Did you read the comments I wrote in your previous threads regarding variable naming conventions?  You will find more willing help if you try to use them.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

http https including www

What I need is

https://test.blogspot.com.tr
https://test.blogspot.com
http://test.blogspot.com.tr
http://test.blogspot.com
test.blogspot.com.tr
test.blogspot.com
or
www.asdf.blogspot.com
www.asdf.blogspot.com.tr
https://www.test.blogspot.com.tr
https://www.test.blogspot.com

 

Posted (edited)

youtuber,

It's not making any sense.

You will have to be more specific.

 

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted

youtuber,

And where is the entries for autoitscript.com?

 

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted (edited)
6 minutes ago, kylomas said:

youtuber,

You want all url's with "BlogSpot"?

kylomas

 

Yes I want all blogspot URLs

Spoiler

4G0QEp.jpg

 

Edited by youtuber
Posted

youtuber,

Just change the SRE...

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>

Global $aListUrl = "https://www.autoitscript.com/forum/" & @CRLF & _
        'https://www.autoitscript.com' & @CRLF & _
        'https://test.blogspot.com.tr' & @CRLF & _
        'https://test.blogspot.com' & @CRLF & _
        'http://test.blogspot.com.tr' & @CRLF & _
        'http://test.blogspot.com' & @CRLF & _
        'test.blogspot.com.tr'

$Form1 = GUICreate("Form1", 830, 668)
$Edit1 = GUICtrlCreateEdit("", 32, 48, 353, 545)
GUICtrlSetData($Edit1, $aListUrl)
GUICtrlSetLimit($Edit1, 90000000)
$Edit2 = GUICtrlCreateEdit("" & @CRLF, 400, 48, 401, 553, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
GUICtrlSetLimit($Edit2, 90000000)
$ExtractSubDomain = GUICtrlCreateButton("Extract", 32, 616, 75, 25, $BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW)
ControlFocus('', '', $ExtractSubDomain)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

            ; this works and follows the technique you were using

;~      Case $ExtractSubDomain
;~          $TestString = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF, 2)
;~          ;_ArrayDisplay($TestString)
;~          For $i = 0 To UBound($TestString) - 1
;~              $sSubdomain = StringRegExp($TestString[$i], '(?:https?:\/\/)?(.*?)\.', 3)
;~              If Not @error Then GUICtrlSetData($Edit2, $sSubdomain[0] & @CRLF, 1)
;~          Next

            ; This is a cleaner, more efficient way

        Case $ExtractSubDomain
            ;$aSubdomain = StringRegExp($aListUrl, '(?im)^(?:https?:\/\/)?(.*?)\.', 3)
            $aSubdomain = StringRegExp($aListUrl, '.*?blogspot.*', 3)
            For $i = 0 To UBound($aSubdomain) - 1
                GUICtrlSetData($Edit2, $aSubdomain[$i] & @CRLF, 1)
            Next

    EndSwitch
WEnd

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

@kylomas Thank you
Is my arrangement correct?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>

Global $aListUrl = "https://www.autoitscript.com/forum/" & @CRLF & _
        'https://www.autoitscript.com' & @CRLF & _
        'https://test.blogspot.com.tr' & @CRLF & _
        'https://test.blogspot.com' & @CRLF & _
        'http://test.blogspot.com.tr/asdfasdf' & @CRLF & _
        'http://test.blogspot.com' & @CRLF & _
        'test.blogspot.com.tr'

$Form1 = GUICreate("Form1", 830, 668)
$Edit1 = GUICtrlCreateEdit("", 32, 48, 353, 545)
GUICtrlSetData($Edit1, $aListUrl)
$Edit2 = GUICtrlCreateEdit("" & @CRLF, 400, 48, 401, 553, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
$ExtractSubDomain = GUICtrlCreateButton("Extract", 32, 616, 75, 25, $BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW)
ControlFocus('', '', $ExtractSubDomain)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

     Case $ExtractSubDomain
         $TestString = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF, 2)
         ;_ArrayDisplay($TestString)
         For $i = 0 To UBound($TestString) - 1
             $sSubdomain = StringRegExp($TestString[$i], '.*?blogspot.*', 3)
             If Not @error Then GUICtrlSetData($Edit2, $sSubdomain[0] & @CRLF, 1)
         Next
    EndSwitch
WEnd

 

Posted

Danp2, Ok.

kylomas, Thanks

youtuber, Glad you got it worked out.

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted

youtuber,

No problem, I suspected a language issue.  Let me encourage you to read the wiki articles regarding arrays.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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
  • Recently Browsing   0 members

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