Sign in to follow this  
Followers 0
AzKay

View Generated Source?

18 posts in this topic

Okay, Ive got an addon for firefox, and it lets me right click > web developer > source > view generated source. What it does is, It gets the "generated" source for the current page. What Im needing it for is:

Ive got a page, once I put in some javascript code, and new thing comes in on the page, though, if I try to _IEBodyReadHtml(), It only retrieves the source from before the javascript command. What the "view generated code does", Is it gets everything thats there, from when you click the "view generated source". Instead of getting what _IEBodyReadHtml gets. Did that make any sense atall? Anyone have any ideas?


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites



Ok, I may aswell kick my topic up before I go to bed.

Night everyone.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

Ok, I may aswell kick my topic up before I go to bed.

Night everyone.

Back.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

I came, I saw, I left with a headache

:whistle:

Share this post


Link to post
Share on other sites

I came, I saw, I left with a headache

:whistle:

So, Doesnt make sense?

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

So, Doesnt make sense?

What gave you that idea ;) ?

Was it the fact that a member said it gave them a headache (to basically understand it), or the fact that 4 out of the 5 post previous were yours? :whistle:


[center]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.[/center]

Share this post


Link to post
Share on other sites

Ill try to rephrase it then.

1: I use firefox, I have a plugin called "Web Developer".

2: I can click Web Developer > View Source > View Generated Source

3: As far as I can gather, It highlights the whole page, then reads the source of the text

Now, Heres my problem.

1: Im making a program for rapidshare.

2: When it gets to the downloading page, I use some javascript, Then it shows the security image, etc.

3: If I just use the normal read source function, It reads the source from before I used the javascript. So, Its not getting the current source.

What I need.

1: A function to view the current source.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

View Rendered Source for IE:

http://billfriedrich.tripod.com/index.html?Web

You could also just do it with IE.au3:

#include <IE.au3>
$oIE = _IECreate("http://www.google.com")
$oDoc = _IEDocGetObj ($oIE)
ConsoleWrite($oDoc.documentElement.innerHTML & @crlf)

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Okay, Ive got an addon for firefox, and it lets me right click > web developer > source > view generated source. What it does is, It gets the "generated" source for the current page. What Im needing it for is:

Ive got a page, once I put in some javascript code, and new thing comes in on the page, though, if I try to _IEBodyReadHtml(), It only retrieves the source from before the javascript command. What the "view generated code does", Is it gets everything thats there, from when you click the "view generated source". Instead of getting what _IEBodyReadHtml gets. Did that make any sense atall? Anyone have any ideas?

I want to set the record straigt here.

Using IE of course, _IEBodyReadHTML, _IEBodyReadText and _IEDocReadHTML all return the "generated" source - a snapshot of the active DOM at the time you make the call. It is NOT the same as what you get from View Source.

One caution would be to use _IELoadWait prior to using the functions to insure that any active updates have first completed.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Well, lod3n, Ill try what you said. Oh, and I googled this, And found this

http://www.thescripts.com/forum/thread95859.html

Maybe that explains it better. Or worse. Lol.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

Ok, Heres my code:

$Obj2 = _IECreate("http://rapidshare.de/files/10513548/NutPack.rarl");GUICtrlRead($Input1))
            $oSubmit = _IEGetObjByName($Obj2, "dl.start", 1)
            _IEAction($oSubmit, "click")
            _IELoadWait($Obj2)
            _IENavigate($Obj2, "java script:c(c=0)", 0)
            Sleep(5000)
            $oSource = _IEDocGetObj($Obj2)
            $ssl = _StringBetween($oSource, '<img src="https://ssl.rapidshare.de/', '".png"> here:"')
            MsgBox(0, "", "https://ssl.rapidshare.de/" & $ssl & ".png")

Func _StringBetween($s, $from, $to)
    $x = StringInStr($s, $from) + StringLen($from)
    $y = StringInStr(StringTrimLeft($s, $x), $to)
    Return StringMid($s, $x, $y)
EndFunc

But this doesnt return anything.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

_IEDocGetObj returns an object variable pointing to a document. That your string isn't matched is no surprise.

_IEBodyReadHTML returns the document source...

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Ah, My mistake, I forgot the last part of lod3n's script. This is what I have now:

$oSource = _IEDocGetObj($Obj2)
            $NewSource = $oSource.documentElement.innerHTML
            $ssl = _StringBetween($NewSource, '<img src="https://ssl.rapidshare.de/', '.png">')
            MsgBox(0, "", "https://ssl.rapidshare.de/" & $ssl & ".png")

I checked the source first, and it does give me what I want, but, i just cant seem to get _StringBetween to get it.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

So you realize that _IEDocReadHTML does a $o_object.document.documentElement.outerHTML -- you can use the _IE function instead of coding it yourself, but that is your choice. I just want to make certain that others that stumble on this topic know that what you are wanting is already built into IE.au3.

I suggest you just need to play with the string functions until you get it right -- from the looks of it you may be running into single/double quoting hell.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

So you realize that _IEDocReadHTML does a $o_object.document.documentElement.outerHTML -- you can use the _IE function instead of coding it yourself, but that is your choice. I just want to make certain that others that stumble on this topic know that what you are wanting is already built into IE.au3.

I suggest you just need to play with the string functions until you get it right -- from the looks of it you may be running into single/double quoting hell.

Dale

Ah, Hehe, Thanks xD

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

Try this:

$prefix = "https://ssl.rapidshare.de/"
$postfix = ".png"
$matchstart = '<img'
$matchend = '>'

$matches = _StrBetween($html, $matchstart,$matchend)

for $i = 0 to ubound($matches)-1
    $match = $matches[$i]
    $found = stringinstr($match,$prefix)
    if $found Then
        $image = stringmid($match,$found)
        $found = stringinstr($image,$postfix)
        if $found Then 
            $image = stringleft($image,($found+stringlen($postfix)-1))
            msgbox(0,"Found image:",$image)
        EndIf
    EndIf
Next

; courtesy of SmOke_N:
Func _StrBetween($sString, $sStart, $sEnd, $vCase = -1, $iSRE = -1)
    If $iSRE = -1 Or $iSRE = Default Then
        If $vCase = -1 Or $vCase = Default Then $vCase = 0
        If $vCase <> -1 And $vCase <> Default Then $vCase = 1
        Local $sHold = '', $sSnSStart = '', $sSnSEnd = ''
        While StringLen($sString) > 0
            $sSnSStart = StringInStr($sString, $sStart, $vCase)
            If Not $sSnSStart Then ExitLoop
            $sString = StringTrimLeft($sString, ($sSnSStart + StringLen($sStart)) - 1)
            $sSnSEnd = StringInStr($sString, $sEnd, $vCase)
            If Not $sSnSEnd Then ExitLoop
            $sHold &= StringLeft($sString, $sSnSEnd - 1) & Chr(1)
            $sString = StringTrimLeft($sString, $sSnSEnd)
        WEnd
        If Not $sHold Then Return SetError(1, 0, 0)
        $sHold = StringSplit(StringTrimRight($sHold, 1), Chr(1))
        Local $aArray[UBound($sHold) - 1]
        For $iCC = 1 To UBound($sHold) - 1
            $aArray[$iCC - 1] = $sHold[$iCC]
        Next
        Return $aArray
    Else
        If $vCase = Default Or $vCase = -1 Then $vCase = '(?i)'
        If $vCase <> Default And $vCase <> -1 Then $vCase = ''
        Local $aArray = StringRegExp($sString, '(?s)' & $vCase & $sStart & '(.*?)' & $sEnd, 3)
        If IsArray($aArray) Then Return $aArray
        Return SetError(1, 0, 0)
    EndIf
EndFunc


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Got it working, Seems it was a case problem. I was using:

$ssl = _StringBetween($NewSource, '<img src="https://ssl.rapidshare.de/', '.png">')
oÝ÷ Ø­"ÈhºWoy·ë"®¶­s`¢b33c·76ÂÒõ7G&æt&WGvVVâb33c´æWu6÷W&6RÂb33²fÇC´Ôr7&3ÒgV÷C¶GG3¢ò÷76Âç&G6&RæFRòb33²Âb33²çærgV÷C²fwC²b33²

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
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
Sign in to follow this  
Followers 0