#23112 - 2002-06-13 02:37 PM
Getting HTML Source Code from IE & Send to Text File
|
Jayson75
Lurker
Registered: 2002-06-12
Posts: 2
Loc: Niagara Falls NY
|
Greetings All,
Hoping someone would know how to script a way to get the source code from a webpage and perhaps send it to a text file (we use IE).
I'm basically putting together a simple test script that will automatically check the source code and compare it to a "successful test". Unfortunately these webpages exist on our client servers which we don't have direct access to (and we often find the problem 1st). If someone could provide a way to just pull the html source code I can do the rest.
Thanks in advance! Jason
|
|
Top
|
|
|
|
#23113 - 2002-06-13 02:59 PM
Re: Getting HTML Source Code from IE & Send to Text File
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Welcome Jayson,
I'm having a bit of trouble getting you exactly the script you may be looking for, but in the meantime, might want to check-out the Internet Stock Quote script - specifically read-up to the point in the script where it fetches the HTML - then you could just write it out to a file. Heres the link, post any questions you may have:
Stock Quotes
-Shawn
|
|
Top
|
|
|
|
#23117 - 2002-06-13 04:51 PM
Re: Getting HTML Source Code from IE & Send to Text File
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
Hmm.. I fiddled around with it and the previous one works fine:
code:
break on $URL = 'http://www.yahoo.com' $ie = createobject("internetexplorer.application") $ie.navigate($URL) while $ie.readystate <> 4 and $ie.busy and @error = 0 loop while $ie.document.readystate <> "complete" and @error = 0 loop $html = $ie.document.documentelement.innerhtml
$html does include the complete text of the file. However, I think there is another way to do this other than using IE or the winhttp.... i'm looking into it.
Brian
|
|
Top
|
|
|
|
#23119 - 2002-06-13 05:07 PM
Re: Getting HTML Source Code from IE & Send to Text File
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
I'm still messing with it, too. I'm not sure about all websites, but I saved the result to a file and opened it and it is a perfect .html of the yahoo website.... the file is also 24,784 long. I was fiddling around with other ways to do this, but I don't see an easy way to write the source code to a file with IE other than the one previously shown. I was able to get it to write a file that was interpreted html, but not the raw source code, although I must admit I'm a novice controlling IE with this method.)
Brian
(I suppose string length becomes an issue at > 32000 characters... so this wouldn't be an adequate test.. On that note, though, shouldn't there be a way to save the document object as source via object method without importing the whole string into an object in KiXtart?) [ 13 June 2002, 17:17: Message edited by: BrianTX ]
|
|
Top
|
|
|
|
#23120 - 2002-06-14 04:12 AM
Re: Getting HTML Source Code from IE & Send to Text File
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
something like this??
code:
break on
$htmlfile = "http://isorg.net" $outfile = "html.txt"
$ie=createobject("internetexplorer.application")
? "Downloading html file" $ie.navigate($htmlfile) while $ie.busy and $ie.readystate <> 4 and @error = 0 sleep(1) "." loop
if $ie.document $doc = $ie.document $data = $doc.documentelement.innerhtml $nul = open(1,$outfile,5) $nul = writeline(1,$data) endif
as far as the string size limit.... i found that as long as your don't try to display large string's, Kix can still handle them.
using the above method i was downloading a inventory file that was on average 170k parsing the information and saving it to the hard disk with out a problem.
Bryce
|
|
Top
|
|
|
|
#23121 - 2002-06-14 04:17 AM
Re: Getting HTML Source Code from IE & Send to Text File
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#23124 - 2002-06-14 04:20 AM
Re: Getting HTML Source Code from IE & Send to Text File
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
shhhhh
I have been lurking, but normally yall beat me to the problems
|
|
Top
|
|
|
|
#23125 - 2002-06-19 01:56 PM
Re: Getting HTML Source Code from IE & Send to Text File
|
Jayson75
Lurker
Registered: 2002-06-12
Posts: 2
Loc: Niagara Falls NY
|
WoW thanks for the quick responses! I'll work in the above examples next week and let you know how it goes. Good news is the pages I need the source code from aren't very large. Thanks again!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 962 anonymous users online.
|
|
|