Jump to content

iFrame


JohnOne
 Share

Recommended Posts

Using Dale's IE UDFs.

I navigate to a webpage, and in it there is a load of iframes

The frame I'm after has no name, but managed to get the frame with posted today (_IEFrameGetObjById). I needed to submit a form in that frame, but unfortunately it is cross domain.

So now I'm needing to navigate to the url of that frame, except I don't know how to cleanly do it.

At the moment I am using _StringBeween() on the whole document body to get the url I want :(

Anyone put me straight on how to do this properly?

This is all I get from the original source of page.

<iframe id="framecfgyyr5dki870" src="http://www.sizzlewizzle.com/embed.php?file=nobby brown picks 3/his.nose.flv" width="530" height="410" frameborder="0" scrolling="no"></iframe>

So instead of using stringbetween, I can get that url with the object reference to the iframe.

here is the basic code.

#include <IE.au3>

$oIE = _IECreate("http://www.superhilariousvideosEx.com/the-big-nose-picking-incident")
If Not IsObj($oIE) Then
    Exit MsgBox(0, "Error", "_IEAttach")
EndIf

$Frame = _IEFrameGetObjById($oIE, "framecfgyyr5dki870")
If Not IsObj($Frame) Then
    Exit MsgBox(0, "Error", "_IEFrameGetObjById")
EndIf

;I need to get the url in that frame tage above more cleanly than string functions here

Func _IEFrameGetObjById(ByRef $o_object, $s_id)
    ;http://www.autoitscript.com/forum/topic/146633-how-to-access-iframes-based-on-id/
    If Not IsObj($o_object) Then
        __IEErrorNotify("Error", "_IEFrameGetObjById", "$_IEStatus_InvalidDataType")
        Return SetError($_IEStatus_InvalidDataType, 1, 0)
    EndIf
    ;
    Local $oTemp, $oFrames

    If Not __IEIsObjType($o_object, "browserdom") Then
        __IEErrorNotify("Error", "_IEFrameGetObjById", "$_IEStatus_InvalidObjectType")
        Return SetError($_IEStatus_InvalidObjectType, 1, 0)
    EndIf

    If __IEIsObjType($o_object, "document") Then
        $oTemp = $o_object.parentWindow
    Else
        $oTemp = $o_object.document.parentWindow
    EndIf

    If _IEIsFrameSet($oTemp) Then
        $oFrames = _IETagNameGetCollection($oTemp, "frame")
    Else
        $oFrames = _IETagNameGetCollection($oTemp, "iframe")
    EndIf

    If $oFrames.length Then
        For $oFrame In $oFrames
            If $oFrame.id = $s_id Then Return SetError($_IEStatus_Success, 0, $oTemp.frames($s_id))
        Next
        __IEErrorNotify("Warning", "_IEFrameGetObjById", "$_IEStatus_NoMatch", "No frames matching Id")
        Return SetError($_IEStatus_NoMatch, 2, 0)
    Else
        __IEErrorNotify("Warning", "_IEFrameGetObjById", "$_IEStatus_NoMatch", "No Frames found")
        Return SetError($_IEStatus_NoMatch, 2, 0)
    EndIf
EndFunc   ;==>_IEFrameGetObjById

Appreciate any input/snidey remarks/whatever you have really.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

G:\Users\Exit>nslookup www.sizzlewizzle.com

*** www.sizzlewizzle.com wurde von fritz.box nicht gefunden: Non-existent domain.

G:\Users\Exit>nslookup www.superhilariousvideosEx

*** www.superhilariousvideosEx wurde von fritz.box nicht gefunden: Non-existent domain.

Can't test it. Non-existent domain.

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
Share on other sites

$sSRCValue = $oFrame.getattribute('src')

Does this example help?

#include  $oIE = _IECreate("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe") $oFrame = _IEGetObjById($oIE, "viewIFRAME") ConsoleWrite($oFrame.src & @CRLF)
Both tests throw com error "The requested action with this object has failed." :(

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

GMK example is working for me on other sites

guess you cant share original url for testing?

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

It is my goal to do this whole process with trancexx' winhttp funtions in the end.

But since I have no idea how to use it, I'm trying to do it with IE first to give me something to follow

while trying to figure out winhttp method.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Does this example help?

#include <IE.au3>
$oIE = _IECreate("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe")
$oFrame = _IEGetObjById($oIE, "viewIFRAME")
ConsoleWrite($oFrame.src &amp;amp; @CRLF)

GMK this works fine, bogQ showed me that it was my code which was wrong.

Thank you both.

EDIT:

jdelaney's code works also, cheers.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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