Jump to content
Shevilie

Remove HTML before show

Recommended Posts

Shevilie

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
Shevilie

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
nooby

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
Shevilie

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
Shevilie

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
Shevilie

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
jvanegmond

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
Shevilie

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
Nareshm
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)

 

Share this post


Link to post
Share on other sites
JLogan3o13
Posted (edited)

@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

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×