Jump to content

Load webpage without image


jedliu
 Share

Recommended Posts

Hi, All,

I would like to know whether it is possible to load the webpage with _IECreateEmbedded() function without loading the images in the webpage?

I knew it could set IE not to load the images, but I only want this to be effected with the IE object which created in the Autoit GUI.

How could it possible?

thanks!

:)

Link to comment
Share on other sites

Maybe...

#include<IE.au3>

; toggle images off
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "no")

$oIE = _IECreate("http://www.Autoit3.com")

$sBodyText = _IEBodyReadText($oIE)
If StringInStr($sBodyText, "Autoit") Then MsgBox(4096, "Great!", "We are here!!!               ", 3)

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "yes")

8)

NEWHeader1.png

Link to comment
Share on other sites

#include <INet.au3>
#include <IE.au3>
$page = "http://google.com"
$source = _INetGetSource($page)
$source = StringRegExpReplace($source, "<img\b[^>]*>", "")
$oIE = _IECreate()
_IEDocWriteHTML($oIE, $source)

Like so? (Only filters the <img> tag, no background images, etc). Also untested.

Edited by KentonBomb
Link to comment
Share on other sites

@Valuater

Thanks, it will applied to IE global setting, I just hope it could effect in the AutoIt GUI.

@KentonBomb

Thanks, get the source code and replace the img tags, it will not show the images to the users.

I am doing this for submitting some data to the server, and what I want is to ease the load of the server, :)

Maybe this couldn't be achieved at the moment.

I am wondering there will option when create IE obj to change the properites at that moment.

hope there some way to solve this, Thx

Edited by jedliu
Link to comment
Share on other sites

You aren't actually loading the images at all with my code. You're just loading the plain-text source, so the images aren't called on at all. You're filtering out the img tag before anything is rendered, then rendering it sans-images. :)

Link to comment
Share on other sites

#include <INet.au3>
#include <IE.au3>
$page = "http://google.com"
$source = _INetGetSource($page)
$source = StringRegExpReplace($source, "<img\b[^>]*>", "")
$oIE = _IECreate()
_IEDocWriteHTML($oIE, $source)

Like so? (Only filters the <img> tag, no background images, etc). Also untested.

the problem with this, is i have tested it.. much earlier.

it DOES filter out whatever you want it to, HOWEVER...

it treats the new, edited page as if it was located on your computer, and none of the links point to the correct place.

which is a big issue especially with javascript actions.

thats where i am stuck.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

I typically have limited time to troll the posts here and try to help. Your other post about this was far too long and rambling for me to spend time on t0ddie.

This sums it up much better.

The reason that the code above treats the page as if it is on your machine is because, well thats where the page was pointed (about:blank) then you updated its HTML.

If you did the same thing on a page you navigate to google, the base URL would be on the google site:

$oIE = _IECreate("http://www.google.com")

_IEDocWriteHTML($oIE, $source)

Make sense?

Dale

Edit: Typo

Edited by DaleHohm

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 did that intentionally, but forgot to change it when I posted it. For some reason, whenever I try to open a Web page via _IECreate(), it opens two IE windows (one pointing to the requested page, and the other to about:blank). I planned to change it before I posted. :)

Edited by KentonBomb
Link to comment
Share on other sites

$oIE = _IECreate("http://www.google.com")

_IEDocWriteHTML($oIE, $source)

Make sense?

Dale

Edit: Typo

yeah it makes sense... and yeah i understood that was happening, i didnt understand exactly why but i had a pretty good idea.. something like you describe.

oh, and thanks for the reply.

i will try to keep rambling to a minimum

but can what I need to get done be accomplished? thats the real question.

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
#RequireAdmin
_IEErrorHandlerRegister ()
$oIE = _IECreateEmbedded ()
GUICreate("Test", 640, 580,0,0, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 40, 0, 900, 600)
GUISetState()
WinSetState("Test","",@SW_MAXIMIZE)
_IENavigate ($oIE, "http://www.starkingdoms.com/login/")
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

that is a simplified version of my script.

i want to lets say, replace a picture on that webpage (pick any) with another one on my harddrive (pick any).

if it can be done, please adjust my code as an example.

the thing is i am creating the $oIE as embedded. no parameters allowed.

i dont use $oIE = _IECreate("http://www.google.com")

I use $oIE = _IECreateEmbedded () and it throws an error when I try to put a url in the parenthesis.

any work-around? or cant it be done inside of a gui?

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Kenton posted a perfect example of how it could be done, Its just up to you to modify your example for it to fit. Its hardly anything hard, its maybe, one param in the StringRegExpReplace.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

#include <INet.au3>
#include <IE.au3>
$page = "http://google.com"
$source = _INetGetSource($page)
$source = StringRegExpReplace($source, "<img\b[^>]*>", "")
$oIE = _IECreate($page)
_IEDocWriteHTML($oIE, $source)

this works BUT

i want to do it with _IECreateEmbedded() and its not allowing parameters.

so what you are saying is I can do this but not in a gui?

also i looked in the helpfile to try to figure it out, still nothing.

No actions can be performed on this object until it has been embedded into a parent application (e.g. you cannot perform an _IENavigate). Because of this restriction, the browser is not automatically navigated to 'about:blank' as is a browser created with _IECreate. You must therefore use _IENavigate to navigate this browser to 'about:blank' after it has been embedded into the parent application and before you attempt any operations that rely on having a document loaded (e.g. _IEBodyWriteHTML).

$test  = 'about:blank'
_IENavigate ($oIE, $test)

but heh, just brings me to a blank page lol. so.... yeah

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

$oIE = _IECreateEmbedded()

_IENavigate($page)

_IEDocWriteHTML($oIE)

nope, does not work. see for yourself.

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
#include <INet.au3>
#RequireAdmin
_IEErrorHandlerRegister ()
$oIE = _IECreateEmbedded ()
GUICreate("Test", 640, 580,0,0, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 40, 0, 900, 600)
GUISetState()
WinSetState("Test","",@SW_MAXIMIZE)
$page = "http://www.google.com"
$source = _INetGetSource($page)
$source = StringReplace($source, "/intl/en_ALL/images/logo.gif", "http://www.diablouniverse.com/DeathStar.gif")
_IENavigate ($oIE, $page)
_IEDocWriteHTML($oIE, $source)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

and nobody answered this guys question yet.. its the same one I have.

I would like to know whether it is possible to load the webpage with _IECreateEmbedded() function without loading the images in the webpage?

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Might want to look at the /en_ALL/, Doesnt work for me, as mine is en_au.

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
#include <INet.au3>
#RequireAdmin
_IEErrorHandlerRegister ()
$oIE = _IECreateEmbedded ()
GUICreate("Test", 640, 580,0,0, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 40, 0, 900, 600)
GUISetState()
WinSetState("Test","",@SW_MAXIMIZE)

$source = _INetGetSource("http://www.google.com")
$source = StringReplace($source, "/intl/en_au/images/logo.gif", "http://www.diablouniverse.com/DeathStar.gif")
_IENavigate ($oIE, "about:blank")
_IEDocWriteHTML($oIE, $source)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

Works if I replace the en_ALL with en_au.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Might want to look at the /en_ALL/, Doesnt work for me, as mine is en_au.

#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <WindowsConstants.au3>
#include <INet.au3>
#RequireAdmin
_IEErrorHandlerRegister ()
$oIE = _IECreateEmbedded ()
GUICreate("Test", 640, 580,0,0, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 40, 0, 900, 600)
GUISetState()
WinSetState("Test","",@SW_MAXIMIZE)

$source = _INetGetSource("http://www.google.com")
$source = StringReplace($source, "/intl/en_au/images/logo.gif", "http://www.diablouniverse.com/DeathStar.gif")
_IENavigate ($oIE, "about:blank")
_IEDocWriteHTML($oIE, $source)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd

Works if I replace the en_ALL with en_au.

what works.

the image is replaced? or the image is replaced, AND the functions on the site work?

or did you not try to click any button, or link......

the image itself.. whether it loads or not will not effect the functionality of the script..

still broken.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Well, I thought you were just trying to replace the image.

yes, replace the image, no, not replace the functionality of the webpage.

i understand this can be done with _IECreate("http://yoursite.com") but can it be done with _IECreateEmbedded()?

I want to use it in a gui.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

You should read again about RegExp because you can for example find <img */*/*> (syntax is not important right now) and replace it's path to your C:\ style path (only root is different) and play with offset so once it get replaced and once it get skipped so it remain in it's valid form. it's all in the help file with several redirection to sources with in-depth explanation.

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...