WebRecorder/IEAuto get source from page

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

WebRecorder/IEAuto get source from page

Post by SteenJakobsen » Fri May 21, 2010 3:44 am

Hi,

Is it possible to get the source form the current loaded page?

I can get the source by rclicking and selecting View Source
then a notepad opens .. but it could be much cleaner if there somehow was another way.. ?
Best Regards
Steen Jakobsen
DM Software A/S

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Fri May 21, 2010 3:51 am

Couldn't You Use MS's function of HTTPRequest?

Code: Select all

HTTPRequest>http://www.mjtnet.com,d:\mjtnet.html,GET,,HTMLResponse
ReadFile>d:\mjtnet.html,Data
MessageModal>%Data%
That Would Save The File To d:\mjtnet.html In Which You Could Then Read That File, Hence Giving You The Source Code?

Let Me Know If That Was What Your After?
FIREFIGHTER

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Fri May 21, 2010 6:51 am

Hi,


No that wont work since the page is only avalible after a login..

Any other idea..?
Best Regards
Steen Jakobsen
DM Software A/S

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Fri May 21, 2010 7:03 am

What Type Of Login Does The Page Have? Does It Pop Up A Auth Box, Or Is It Via A Web Form?

You Could Still Use The Web Recorder & Include The Macro Scheduler Command Afterwards.
FIREFIGHTER

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Fri May 21, 2010 7:47 am

Hi again,

I just tried your example end it justv return the loginpage .. note page that is actually active..

However if i rclick the table on the page then I can export the complete source and then extract data from it.
The table i very complex and can not be extracted using webrecorder.
(Or I do not know how to..)
Thats why I'm after a way to gelt hold of the source - other than automating notepad :-)
Best Regards
Steen Jakobsen
DM Software A/S

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 21, 2010 9:12 am

To get the HTML source of the page use the ExtractTag function for the HTML or BODY tag, specifying ALL html. Just remember to set the buffer size really high - if it's too low it may crash as it writes passed the end of the buffer:

Code: Select all

// Generated by MacroScript WebRecorder 2.3
// Recorded on  Friday, May 21, 2010, at 10:15 AM
LibLoad>IEAuto.dll,hIE
If>hIE=0
  MessageModal>Could not load IEAuto.dll, make sure it is in the path or edit the LibLoad line.
  Goto>end_script
EndIf

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1

LibFunc>hIE,CreateIE,IE[2],0

LibFunc>hIE,Navigate,r,%IE[2]%,www.mjtnet.com
LibFunc>hIE,WaitIE,r,%IE[2]%
Wait>delay

//Modify buffer size if required ...
Let>BODYHTML_SIZE=99999999
LibFunc>hIE,ExtractTag,r,%IE[2]%,,BODY,0,1,BODYHTML
MidStr>r_6,1,r,BODYHTML

MessageModal>BODYHTML

LibFree>hIE
Label>end_script
Note the entire HTML for the BODY of the page is extracted. Specify HTML instead of BODY if you need the headers.

Now you have the BODY you could parse it with RegEx or whatever you want to do.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Sun May 23, 2010 5:28 am

Thanks a lot Marcus :-)
Best Regards
Steen Jakobsen
DM Software A/S

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Sun May 23, 2010 12:08 pm

Hi marcus,

It works fine some times.
However sometimes it give me this error

Error in : C:\DOCUME~l\AFDM\LOKALE~l\Temp\_debug.dbg
Line: 286 - Error Calling DLL - Possible wrong number or type of parameters.


It is the exact same code but just a bit further down in the script.
It seems that if LibFunc>hIE... has been called a couple of times then the error comes..
Any clue ?
Best Regards
Steen Jakobsen
DM Software A/S

SteenJakobsen
Pro Scripter
Posts: 110
Joined: Thu Apr 08, 2010 6:11 am
Location: Hørsholm, Denmark
Contact:

Post by SteenJakobsen » Mon May 24, 2010 8:27 pm

Hi Marcus,

I have worked it out .. and it WORKS GREAT now :-)

The trick was to specify the frame and form arguments.
(Just liteh when clicking a BUTTON - se other post)

The the syntax error disapeared and the results were correct.

Mybe you shuld add a comment in the Doc's about it :-)

Thanks for your help
Best Regards
Steen Jakobsen
DM Software A/S

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts