AutID Posted August 29, 2015 Share Posted August 29, 2015 (edited) Hello,I dealing with a html source code and I have a text like this:Dim $sString = '<a href="/track/867059" itemprop="url" class="evt-click" data-target="track">' & _ '<span itemprop="name">Feel So Good </span>' & _ '</a>' & _ '<span class="featuring" data-target="featuring"></span>' & _ '</div>' & _ '</td>' & _ '<td class="artist">' & _ '<div class="wrapper ellipsis">' & _ '<a class="evt-click" href="/artist/7" data-target="artist" itemprop="byArtist">Jamiroquai</a>' & _ '</div>' & _ '</td>' & _ '<td class="album">' & _ '<div class="wrapper ellipsis">' & _ '<a class="evt-click" href="/album/98952" itemprop="inAlbum" data-target="album" >A Funk Odyssey</a>' & _ '</div>' & _ '</td>' & _ '<td class="length">' & _ '<div class="wrapper" data-target="length"></div>' & _ '</td>' & _ '<td class="popularity" title="By popularity:7.85 / 10">' & _ '<span class="note" data-target="note"></span>' & _ '</td>' & _ '<td class="added">' & _ '<div class="wrapper ellipsis timestamp" data-target="added">' & _ '05:23' Dim $sRet = StringRegExp($sString, 'sPattern') ConsoleWrite($sRet & @LF)and I want to get the05:23at the end of the line. I can do it but not with regex. How would the pattern for this look like?Cheers Edited August 29, 2015 by AutID https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
guinness Posted August 29, 2015 Share Posted August 29, 2015 (edited) Please don't use Dim if you can avoid it. In this case you can.Why don't you try with native string functions first? Would be good practice.If your answer to the later was you did, then great. Show us.(\d{2}:\d{2})$ << based on the content Edited August 29, 2015 by guinness Missing group UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
AutID Posted August 29, 2015 Author Share Posted August 29, 2015 It is the laft 5 letters of the string + it has an operator between the numbers. How difficult can that be?I came up with something like this: data-target="added">(.*?)$However since I am actually dealing with digits, I believe your method is better. https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
jguinch Posted August 29, 2015 Share Posted August 29, 2015 This ?Local $sString = '<a href="/track/867059" itemprop="url" class="evt-click" data-target="track">' & _ '<span itemprop="name">Feel So Good </span>' & _ '</a>' & _ '<span class="featuring" data-target="featuring"></span>' & _ '</div>' & _ '</td>' & _ '<td class="artist">' & _ '<div class="wrapper ellipsis">' & _ '<a class="evt-click" href="/artist/7" data-target="artist" itemprop="byArtist">Jamiroquai</a>' & _ '</div>' & _ '</td>' & _ '<td class="album">' & _ '<div class="wrapper ellipsis">' & _ '<a class="evt-click" href="/album/98952" itemprop="inAlbum" data-target="album" >A Funk Odyssey</a>' & _ '</div>' & _ '</td>' & _ '<td class="length">' & _ '<div class="wrapper" data-target="length"></div>' & _ '</td>' & _ '<td class="popularity" title="By popularity:7.85 / 10">' & _ '<span class="note" data-target="note"></span>' & _ '</td>' & _ '<td class="added">' & _ '<div class="wrapper ellipsis timestamp" data-target="added">' & _ '05:23' Local $aRet = StringRegExp($sString, '[\d:]+$', 1) ConsoleWrite($aRet[0] & @LF) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
guinness Posted August 29, 2015 Share Posted August 29, 2015 I have updated mine, as I could have sworn there was trailing space after the value. The only difference between mine and @jguinch, is mine matches two digits, colon and two digits. There's will match something like this 109:19 or :::::1982:192:::1029. So my regex is more explicit in that sense. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
SugarBall Posted September 1, 2015 Share Posted September 1, 2015 Hey, by the way how can you get the "added" at data-target="added"and then click it with IEAction not ConsoleWrite? please help Link to comment Share on other sites More sharing options...
jguinch Posted September 1, 2015 Share Posted September 1, 2015 If you want to use _IEAction, you have to get the DIV as an object.With _IETagNameGetCollection, you can list all DIV objects. Next, check for each object if the data-target value is "added", then use _IEAction with the object.Example :Local $oDivs = _IETagNameGetCollection($oIE, "div") For $oDiv In $oDivs $sDataTarget = Execute("$oDiv.attributes.getNamedItem('data-target').value") If $sDataTarget = "added" Then _IEAction($oDiv, "click") Next(note I used Execute to avoid any oject error, I don't know if this method is good or not...) SugarBall 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
SugarBall Posted September 1, 2015 Share Posted September 1, 2015 Ohhh GOD BLESSS you man, thanks a billion times..... you made my day .... thanks thanks thanksmuch love my friend oh godd Link to comment Share on other sites More sharing options...
jguinch Posted September 1, 2015 Share Posted September 1, 2015 keelp calm, please Glad to help you. SugarBall 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
SugarBall Posted September 1, 2015 Share Posted September 1, 2015 Yes, thank you.. one last thing if its not a bother pleasewhat if i have some other DataTargets and i want to click them one by one, can i make it with Do...Until or Loop... or i dont know Link to comment Share on other sites More sharing options...
jguinch Posted September 1, 2015 Share Posted September 1, 2015 With my previous code, the _IEAction depends of the condition (if the data-target attribute is "added")Either remove the condition, or make a different one.If you want to click on each DIV having a data-target attribute, you can replace the condition by this one :If $sDataTarget <> "" Then _IEAction($oDiv, "click") Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
SugarBall Posted September 1, 2015 Share Posted September 1, 2015 Should i just replace that or put the other attributes like this: If $sDataTarget <> "added1, added2" Then _IEAction($oDiv, "click") Link to comment Share on other sites More sharing options...
jguinch Posted September 1, 2015 Share Posted September 1, 2015 No, you must use a logical operator (look at the help file in Language Reference / Operators)Also, you can use Select or Switch (again, in the help file in Language Reference / Conditional Statements)If $sDataTarget = "added1" Or $sDataTarget = "added2" Then _IEAction($oDiv, "click") Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
SugarBall Posted September 1, 2015 Share Posted September 1, 2015 yes it did work perfectly, sorry for delay... and can i make it with time intervals this clicking? Link to comment Share on other sites More sharing options...
jguinch Posted September 1, 2015 Share Posted September 1, 2015 Use Sleep SugarBall 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now