litlmike Posted August 30, 2007 Share Posted August 30, 2007 If a link appears more than once, I want to skip one of the occurences. In this example it will display 2 occurences of the same link, because the same link appears twice on the page. I would like to skip one of those occurrences. TIA #include <IE.au3> $s_Url = "http://www.youtube.com/results?search_query=Miss+Teen+USA+South+Carolina&search=Search" $sVid = "http://www.youtube.com/watch?v=" $oIE = _IECreate ($s_Url,1) $oLinks = _IELinkGetCollection ($oIE) For $oLink In $oLinks If StringInStr ($oLink.href, $sVid) Then MsgBox (0, "", $oLink.href, 1) EndIf Next _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
narayanjr Posted August 30, 2007 Share Posted August 30, 2007 every link it finds put it into an array then check every link you find to see if it is already in the array and if it is do nothing otherwise do something Link to comment Share on other sites More sharing options...
litlmike Posted August 30, 2007 Author Share Posted August 30, 2007 every link it finds put it into an array then check every link you find to see if it is already in the array and if it is do nothing otherwise do somethingHow do I check if it is already in the array? _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
litlmike Posted August 30, 2007 Author Share Posted August 30, 2007 (edited) Can someone tell me why the first script here works, but not the second script? The second script seems to just jump to the end and never evaluates the last 3 lines. #include <IE.au3> #include <Array.au3> $s_Url = "http://www.youtube.com/results?search_query=Miss+Teen+USA+South+Carolina&search=Search" $sVid = "http://www.youtube.com/watch?v=" $oIE = _IECreate ($s_Url,1) $oLinks = _IELinkGetCollection ($oIE) $Counter=1 $avArray = _ArrayCreate ( "test", "test2") _ArrayDisplay( $avArray, "Whole array" ) _ArrayAdd( $avArray,"Test3") _ArrayDisplay( $avArray, "Updated Array" )oÝ÷ Ù«¢+Ø¥¹±Õ±Ðí%¹ÔÌÐì(¥¹±Õ±ÐíÉÉä¹ÔÌÐì((ÀÌØíÍ}UÉ°ôÅÕ½Ðí¡ÑÑÀè¼½ÝÝܹå½ÕÑÕ¹½´½ÉÍÕ±ÑÌýÍÉ¡}ÅÕÉäõ5¥ÍÌQ¸UMM½ÕÑ É½±¥¹µÀíÍÉ õMÉ ÅÕ½Ðì(ÀÌØíÍY¥ôÅÕ½Ðí¡ÑÑÀè¼½ÝÝܹå½ÕÑÕ¹½´½ÝÑ ýØôÅÕ½Ðì(ÀÌØí½%ô}% ÉÑ ÀÌØíÍ}UÉ°°Ä¤(ÀÌØí½1¥¹Ìô}%1¥¹Ñ ½±±Ñ¥½¸ ÀÌØí½%¤(ÀÌØí ½Õ¹ÑÈôÄ(ÀÌØíÙÉÉäô}ÉÉå ÉÑ ÅÕ½ÐíÑÍÐÅÕ½Ðì°ÅÕ½ÐíÑÍÐÈÅÕ½Ðì¤()½ÈÀÌØí½1¥¹¬%¸ÀÌØí½1¥¹Ì(%}ÉÉå ÀÌØíÙÉÉä°ÀÌØí½1¥¹¬¹¡É¤)9áÐ()}ÉÉå¥ÍÁ±ä ÀÌØíÙÉÉä°ÅÕ½Ðí]¡½±ÉÉäÅÕ½Ðì¤)}ÉÉå ÀÌØíÙÉÉä°ÅÕ½Ðí É¥¸ÅÕ½Ðì¤)}ÉÉå¥ÍÁ±ä ÀÌØíÙÉÉä°ÅÕ½ÐíUÁÑÉÉäÅÕ½Ðì Edited August 30, 2007 by litlmike _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 30, 2007 Moderators Share Posted August 30, 2007 (edited) #include <IE.au3> #include <array.au3> $s_Url = "http://www.youtube.com/results?search_query=Miss+Teen+USA+South+Carolina&search=Search" $sVid = "http://www.youtube.com/watch?v=" $oIE = _IECreate ($s_Url,1) $oLinks = _IELinkGetCollection ($oIE) $aUnique = oLinkUnique($oLinks) _ArrayDisplay($aUnique) Func oLinkUnique($oObLink) If IsObj($oObLink) = 0 Then Return SetError(1, 0, "") Local $sHold = "", $vDelim = Chr(1) For $oLink In $oObLink If StringInStr($vDelim & $sHold, $vDelim & $oLink.href & $vDelim) = 0 Then $sHold &= $oLink.href & $vDelim EndIf Next If $sHold Then Return StringSplit(StringTrimRight($sHold, 1), $vDelim) Return SetError(2, 0, "") EndFunc Edited August 30, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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