Jump to content

Remove HTML before show


Recommended Posts

Hey

I'm looking for a way to remove and write stuff to a internet page before it gets show.. Rigth now i got this

#include <IE.au3>
$oIE = _IECreate("http://www.google.com")
$carrier = _IEBodyReadHTML($oIE)
$carrier = StringReplace($carrier, "Google", "NEW GOOGLE")
_IEBodyWriteHTML($oIE, $carrier)

But as you see the normale page is getting loaded and is visible before my changes is made, is there a way to get the page source, change the html then show it.

I tried _INetGetSource, but then the pictures wouldnt load, and I have to change all URL etc.. That was a mess :shocked:

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Link to comment
Share on other sites

Sloppy way: InetGetSource, and proceed to replace the text within the source string (to whatever you want to change), and finally.. something like this?

FileWrite(@ScriptDir & "\New.htm", $SourceString)
While NOT FileExists(@ScriptDir & "\New.htm") ;Avoid running the file before it's created
    Sleep(5)
WEnd
ShellExecute(@ScriptDir & "\New.htm")

Just giving some (sloppy) ideas.

Link to comment
Share on other sites

In researching this, I find _IEDocWriteHTML will replace the entire HTML that is seen. You could read the HTML, then rewrite what you want with the captured data

Now have a look what I'm doing in the top :shocked:

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Link to comment
Share on other sites

Youre still not loading the html.. if you remove a large object there will still be white space where the object was :)

That is definitely an error on your part. This code removes the image tags from Google, and there isn't any white space at all.

#include <IE.au3>
#include <INet.au3>


$HTML = _INetGetSource("www.google.com")

$HTML = StringRegExpReplace($HTML, "<img.*?>", "")

$oIE = _IECreate("www.google.com", 0,0,1)
_IEBodyWriteHTML($oIE,$HTML)

_IEAction($oIE, "visible")

You have to keep in mind that the website may be using CSS to space and place 'modules' on their website. If you remove one of these modules, you will leave a white space, as the CSS tells the browser that that space has to be there!

Link to comment
Share on other sites

  • 10 years later...
On 4/27/2007 at 4:17 AM, Shevilie said:

Hey

 

I'm looking for a way to remove and write stuff to a internet page before it gets show.. Rigth now i got this

 

 

#include <IE.au3>
$oIE = _IECreate("http://www.google.com")
$carrier = _IEBodyReadHTML($oIE)
$carrier = StringReplace($carrier, "Google", "NEW GOOGLE")
_IEBodyWriteHTML($oIE, $carrier)

 

But as you see the normale page is getting loaded and is visible before my changes is made, is there a way to get the page source, change the html then show it.

 

I tried _INetGetSource, but then the pictures wouldnt load, and I have to change all URL etc.. That was a mess :shocked:

try This :

#include <IE.au3>
$oIE = _IECreate()
WinSetState("[CLASS:IEFrame]", "", @SW_HIDE)
_IENavigate($oIE, "http://www.google.com")
$carrier = _IEBodyReadHTML($oIE)
$carrier = StringReplace($carrier, "Google", "NEW GOOGLE")
_IEBodyWriteHTML($oIE, $carrier)
WinSetState("[CLASS:IEFrame]", "", @SW_SHOW)

 

Link to comment
Share on other sites

  • Moderators

@Nareshm Why would you resurrect a thread after 11 years?! Especially when the OP has already been provided an answer. You have been around long enough to know better; please think before you post next time.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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