Jump to content

get page source problem


Recommended Posts

I use IE to log in & then i use this code to get page source, but the problem is that according to the source I get, im not logged in.

Hire is sample if someone is unable to understand:

When logged in Source code has word letters in it

If not logged in source code does not have word letters in it

I want to get that word letters, so why im getting the source code without letters, even tho i logged in with IE?

Do i need to use this ObjCreate thing to log in somehow?

;=================================
    $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    $oHTTP.Open("GET",'http://www.sampleurl.com)
    $oHTTP.Send()
    ;=================================
    $HTMLSource = $oHTTP.Responsetext
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

Wait a minute, so you open an IE window, login, then run this script? If thats the case you probably won't get the contents of the logged in page since you are basically opening two seperate sessions.

Link to comment
Share on other sites

Wait a minute, so you open an IE window, login, then run this script? If thats the case you probably won't get the contents of the logged in page since you are basically opening two seperate sessions.

Yes you understood correctly. So its impossible to get that logged in page source code with this kind of code? Or maybe its possible to merge those 2 sessions somehow? no?

The reason i use this code cuz its Insanely fast. I tried other code with _IEBodyReadHTML but that one takes 10+ seconds to get the code :)

Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

You probably have to use _IEAttach to attach to the instance you already have open. The only other way is using WinHttpRequest to POST the correct headers containing valid session information.

Link to comment
Share on other sites

You probably have to use _IEAttach to attach to the instance you already have open. The only other way is using WinHttpRequest to POST the correct headers containing valid session information.

_IE attach is no good, (it will be long to explain why.) Would you mind making 1 small sample code how to do the post headers thing, so I could experiment with it?

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

_IE attach is no good, (it will be long to explain why.)

I'd be interested in why...

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

Link to comment
Share on other sites

I'd be interested in why...

Dale

1)He means the speed.Speed first.funtion 2nd.I'm agree with him.

2)Object will give him a good solution to every Program language,his code will be easily transplanted.It's also a good news to me,too.

Edited by AU3Newbie
Link to comment
Share on other sites

1)He means the speed.Speed first.funtion 2nd.I'm agree with him.

2)Object will give him a good solution to every Program language,his code will be easily transplanted.It's also a good news to me,too.

I'm not sure your assumption is correct. If the IE session does not already exist, then yes, the IE functions pay the cost of starting IE. If the browser is already running and pointed to the desired site then speed is not likely the issue (you are accessing locally cached data at that point so there is not even a trip to the server).

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

Link to comment
Share on other sites

Every page handles login info differently but here is an example. This should authenticate a username and password and if they are correct redirect you to Google. You should see the Google html source output to the console.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "http://www.fallenstar.net/fakelogin.php")
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.Send("username=Username&password=Password")
ConsoleWrite($oHTTP.ResponseText & @CRLF)

Func MyErrFunc()
   $HexNumber=hex($oMyError.number,8)
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Windescription is: " & $oMyError.windescription )
   SetError(1)
Endfunc
Link to comment
Share on other sites

Every page handles login info differently but here is an example. This should authenticate a username and password and if they are correct redirect you to Google. You should see the Google html source output to the console.

I was thinking & thinking & more thinking.. so I went to bed & i see things bit more clearly now. _IEAttach does work (so i simply do controlsend URL to IE to refresh the page & get new source & it can work in the background then, but this still means I must wait until IE loads.)

Code:

#include <IE.au3>
_IECreate('http://www.autoitscript.com/')
$oIE = _IEAttach ("AutoIt"); Attach to a browser with "AutoIt" in its title, display the URL
$HTMLSource = _IEPropertyGet ($oIE, "outerhtml")
clipput($HTMLSource)oÝ÷ Øuë^(º{ZázZ zZë(º·µée²g­+¡×ºÒÇ+
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
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...