EvAsion 0 Posted October 11, 2007 How can i get the link that an image points to in an internet explorer object? I was thinking: $oInputs = _IETagNameGetCollection ($oIE, "img") $sHtml = _IEBodyReadHTML($oIE) ;ClipPut($sHtml) $blah = StringRegExp($sHtml,'target=_xtr><IMG alt=["]{0,1}(.*?)["]{0,1} src',1) For $a In $oInputs ;msgbox(0,"",$blah[0]&" "&$a.alt&" "&$a.href) If Not $a.alt = 0 Then If $a.alt = $blah[0] Then msgbox(0,"",$a.href) ;_IECreate($a.href) ExitLoop EndIf EndIf Next But $a.href just returns the src of the image(same as $a.src) |-- Periodic Table --||-- Dynamic Class Timetable --||-- Navigation in Counter-Strike --| Share this post Link to post Share on other sites
Nahuel 1 Posted October 11, 2007 Mmm.. this works for me: $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("GET", "http://www.autoitscript.com/", False) $oHTTP.Send() $oString = StringRegExp($oHTTP.ResponseText, '<a href="(.*?)"><img', 3) For $i = 0 To UBound($oString) -1 MsgBox(0,"",$oString[$i]) Next I'm not sure about the matching pattern in the StringRegExp function though... Share this post Link to post Share on other sites
big_daddy 20 Posted October 11, 2007 The href property you are looking for is actually that of the parent anchor (a). Here is an example of how to access it. #include <IE.au3> $iIndex = 0 $sInfo = "" $sURL = "www.autoitscript.com" _IEErrorHandlerRegister() $oIE = _IECreate($sURL) $oIMGs = _IEImgGetCollection($oIE) ConsoleWrite("Total of " & @extended & " images" & @CR & @CR) For $oIMG In $oIMGs $sInfo &= "Index: " & $iIndex & @CR $sInfo &= @TAB & "Alt: " & $oIMG.alt & @CR $sInfo &= @TAB & "Name: " & $oIMG.nameProp & @CR $sInfo &= @TAB & "SRC: " & $oIMG.src & @CR $oLink = $oIMG.parentElement If $oLink.tagName = "a" Then $sInfo &= @TAB & "Link: " & $oLink.href & @CR EndIf $sInfo &= @CR $iIndex += 1 Next ConsoleWrite($sInfo) Share this post Link to post Share on other sites
Nahuel 1 Posted October 11, 2007 Oh cool I really want to learn how to work with objects properly. This is what I had done, which I thought was closer to what he wanted: #include <IE.au3> $link="http://www.autoitscript.com/" $oIE=_IECreate($link) $sHtml = _IEBodyReadHTML($oIE) $blah = StringRegExp($sHtml,'(?i)<a href="(.*?)"><img',3) For $a=0 To UBound($blah)-1 MsgBox(0,"Image Link Found",$blah[$a]) $check=StringSplit($blah[$a],":") If $check[1]="http" Then MsgBox(0,"","Going to: "&$blah[$a]) _IECreate($blah[$a]) Else MsgBox(0,"","Going to: "&$link&$blah[$a]) _IECreate($link&$blah[$a]) EndIf Next Share this post Link to post Share on other sites
EvAsion 0 Posted October 11, 2007 Thanks so much for your replies, your method works perfect big daddy =D |-- Periodic Table --||-- Dynamic Class Timetable --||-- Navigation in Counter-Strike --| Share this post Link to post Share on other sites