Source language: Translate to:

SendKeys Select All Web Browser Object?

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Postby beno » Thu Sep 21, 2006 8:06 pm

Mmmmhh...

It seems that if I place a NB variable inside the HTML file I can play freely with what to display there.... mmmmhh..

Just neuronstormin´

beno
User avatar
beno
 
Posts: 678
Joined: Fri Apr 01, 2005 9:03 am
Location: México

Postby Gaev » Fri Sep 22, 2006 5:05 am

beno:
... suppose I would like to save the web page with the new image associated... I tried to:
BrowserExport "WebBrowser1" "[MyHTMLCode]"
But inside [MyHTMLCode] there is the original source for the image.
For my project it would be great if I´m able to save the HTML code with the "new" image reference.
I do not find how to accomplish this...
Any idea?

a) BrowserExport will only save the "original source content" ... i.e. the one used to initially load the Browser object ... either from a file or via BrowserLoadFromStr ... same problem happens when you enter text in a form's TextEntry Box (or select an option) and then do a BrowserExport ... the changes are NOT reflected in the exported content.

b) I haven't tried this myself ... but you could experiment with ...
Code: Select all
var gkHTML = document.body.outerHTML ;
window.external.nbSetVar ('[MyVar]', gkHTML) ;

I recall that this will give you everything from "<body ...." to "...</body>" ; and reflects the real time state !!!

c) But this may still not be sufficient as a save/restore facility ... if it relies on (changed since loaded) values for variables and styles in the <head>...</head> section.
document.images[0].src = "file:///c:/path/myimage.jpg"

Tip: if you include an id for each element in your original html source e.g ...
Code: Select all
<img id="beno1" src= "...">

... you can then refer to it directly with ...
Code: Select all
document.getElementById("beno1").src ="..." ;

It seems that if I place a NB variable inside the HTML file I can play freely with what to display there

Not sure what you mean ... but if you have a source file with [neoVariables] ... and you FileRead+BrowserLoadFromStr ... yes, what is loaded might have the resolved values ... but I doubt that it automatically changes when you change the values of such [neoVariables] with NeoBook's SetVar command.
User avatar
Gaev
 
Posts: 3735
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby beno » Fri Sep 22, 2006 9:58 am

Hi Gaev,

var gkHTML = document.body.outerHTML ;
window.external.nbSetVar ('[MyVar]', gkHTML) ;


I tried this and returns all the HTML code and contents, from <body> to </body>, including these tags.

var gkHTML = document.body.innerHTML ;
window.external.nbSetVar ('[MyVar]', gkHTML) ;


This one returns all the HTML code and contents, from <body> to </body>, WITHOUT these tags.

Very useful for my project.

Now, going back to the idea on how to get the actual/modified HTML inside the page... these both does this!, so now I can get all images and links, change them to whatever I want and save/do anything with the HTML.

Wow!, thanks one googol Gaev!

This has been a real nice jmpstart to learn new things!

With these new tools I will be able to replace some clumsy code that I wrote for my project, make things easier, safer, and smarter!!

Ok, now my ideas are a little bit hazy, but this weekend I will make them clear and code all this new approach. I will report here...

Thanks again!

saludos,

beno
User avatar
beno
 
Posts: 678
Joined: Fri Apr 01, 2005 9:03 am
Location: México

Postby domino » Fri Sep 22, 2006 10:11 am

Make up a file called getInnerText.txt with this code (content) ...
Code: Select all
// get innerText of body
var gkText = document.body.innerText ;
window.external.nbSetVar( '[innerText]', gkText ) ;


Just a quick note to say thanks for this snippet Gaev ... it's works a treat... and more suited to automation than the SendKeys

For the terminally bored I`ve just loaded up my little routine with 350,000 characters relating to a theme (grabbed from Webpages.. text etc) .. run these through the common word filters and topic filters etc... and ended up with 2620 strong to medium keywords for my crossword wordlist...


As a matter of interest it took about 15 minutes to process (but able to keep working on other stuff .... dual core rules!) . Creating a list half this size manually used to take me a day at least)

Have been following the rest of this thread with interest.....

Cheers
Dave
User avatar
domino
 
Posts: 275
Joined: Sat Apr 02, 2005 7:11 am
Location: Notts UK

Previous

Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest