Jump to content

Recommended Posts

Posted

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
Posted

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

Posted (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¸­UM­M½ÕÑ ­
ɽ±¥¹µÀíÍÉ õMÉ ÅÕ½Ðì(ÀÌØíÍY¥ôÅÕ½Ðí¡ÑÑÀè¼½ÝÝܹå½ÕÑÕ¹½´½ÝÑ ýØôÅÕ½Ðì(ÀÌØí½%ô}%
ÉÑ ÀÌØíÍ}Uɰ°Ä¤(ÀÌØí½1¥¹­Ìô}%1¥¹­Ñ
½±±Ñ¥½¸ ÀÌØí½%¤(ÀÌØí
½Õ¹ÑÈôÄ(ÀÌØíÙÉÉäô}ÉÉå
ÉÑ ÅÕ½ÐíÑÍÐÅÕ½Ðì°ÅÕ½ÐíÑÍÐÈÅÕ½Ðì¤()½ÈÀÌØí½1¥¹¬%¸ÀÌØí½1¥¹­Ì(%}ÉÉå ÀÌØíÙÉÉä°ÀÌØí½1¥¹¬¹¡É¤)9áÐ()}ÉÉå¥ÍÁ±ä ÀÌØíÙÉÉä°ÅÕ½Ðí]¡½±ÉÉäÅÕ½Ðì¤)}ÉÉå ÀÌØíÙÉÉä°ÅÕ½Ðí   É¥¸ÅÕ½Ðì¤)}ÉÉå¥ÍÁ±ä ÀÌØíÙÉÉä°ÅÕ½ÐíUÁÑÉÉäÅÕ½Ðì
Edited by litlmike
  • Moderators
Posted (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 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.

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
×
×
  • Create New...