danield
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 11/24/2011
-
Status: offline
|
Help! I need get source code from an external site.
Monday, November 28, 2011 5:52 AM
( permalink)
I have the function below to get the source code from an external site. But it presents a problem, because the result of the variable is the owner source code of my program. Can anyone help? My function: Set ie = CreateObject("InternetExplorer.Application") ie.Navigate ("www.google.com") ie.Visible = False while ie.busy Rem Wscript.Sleep 10 Wend sourcefc = ie.Document.body.innerhtml document.write(sourcefc) I need: the source code from an external site. Thanks.
|
|
|
|
59cobalt
-
Total Posts
:
971
- Scores: 91
-
Reward points
:
0
- Joined: 7/17/2011
-
Status: online
|
Re:Help! I need get source code from an external site.
Monday, November 28, 2011 6:35 AM
( permalink)
What you have there is a code snippet, not a function. That said, ie.Document.Body.InnerHTML should return the source code of the page you navigate()'d to. What does ie.Document.Body.InnerHTML actually return? Check with something like "WScript.Echo Left(sourcefc, 1000)". What do you see when you set ie.Visible = True? And where do you write sourcefc to? You should also uncomment the "WScript.Sleep 10" line, otherwise your code will hog system resources while it's busy waiting for Internet Explorer to finish launching.
|
|
|
|
Hackoo
-
Total Posts
:
104
- Scores: 4
-
Reward points
:
0
- Joined: 6/25/2010
-
Status: offline
|
Re:Help! I need get source code from an external site.
Monday, November 28, 2011 8:42 AM
( permalink)
Hi ! Try this code : Call GetSourceHtml Function GetSourceHtml Set ie = CreateObject("InternetExplorer.Application") Set fso = CreateObject("Scripting.FileSystemObject") dim adresse adresse = "http://www.google.com" ie.Navigate (adresse) Do While ie.Busy WScript.Sleep (100) Loop WScript.Sleep (1000) GetSourceHtml = ie.document.body.innerhtml Set OutPut = fso.CreateTextFile("sourcehtml.txt",2) OutPut.WriteLine GetSourceHtml MsgBox GetSourceHtml,64,"Source HTML" ie.Quit Set ie=Nothing Explorer "sourcehtml.txt" End Function Function Explorer(File) Set ws=CreateObject("wscript.shell") ws.run "Explorer "& File & "\" end Function
|
|
|
|