Sign in to follow this  
Followers 0
Shevilie

Remove HTML before show

12 posts in this topic

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

Share this post


Link to post
Share on other sites



I thouhgt of i double browser.. one hidden loading the stuff and then one that is visible.. though i get problems with link and images etc..


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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

No you cant use that... you will still have problems with the link and images since they are relative path....


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

Share this post


Link to post
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

Share this post


Link to post
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 :)


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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Ye it use CSS, but I'm removing the divs.. Hmm but I can see your right, well thx for the help :)


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

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