joe.afusco
Board Regular
- Joined
- Jun 25, 2010
- Messages
- 80
Now, I know this is typically a forum for VBA, but I also know there are many extremely knowledgeable people here, which I can't seem to find on any VBS forum. So, I apologize if this is too far out context.
I am attempting to rip some text from a webpage, eventually bringing the data into excel for manipulation. Here is a working VBS script that completes that task:
The issue is, when I attempt it on a larger webpage, it fails, for what I assume to be too much text to handle. The website I am trying to rip the text off of is sometimes very large, so I am looking for a solution that isn't limited. I'm sure someone out that has had to accomplish this before.
The reason I am using VBS, is because I know VBS can access elements of a webpage, input fields, buttons, etc. Not sure if VBA can do that. I'm open to a VBA solution if it can accomplish logging into a webpage, stripping the data, and jamming it in Excel.
Any thoughts? Thanks in advance for any help.
I am attempting to rip some text from a webpage, eventually bringing the data into excel for manipulation. Here is a working VBS script that completes that task:
Code:
'sub to wait for page loading
Sub WaitForLoad(obj)
Do While ie.Busy: Loop
Do While obj.readyState <> 4: Loop
wscript.sleep(100)
End Sub
'create internet explorer object
Set ie = WScript.CreateObject("InternetExplorer.Application")
'setup ie properties
ie.ToolBar = 1
ie.StatusBar = 1
ie.Width = 999
ie.Height = 999
ie.Left = 0
ie.Top = 0
ie.Visible = 0
ie.Navigate("http://en.wikipedia.org/wiki/Rdio")
WaitForLoad(ie)
websiteText = ie.Document.Body.innerText
Set fso = CreateObject("Scripting.FileSystemObject")
'OpenTextFile Parameters:
'-Filename
'-The 2 is for writing... 1 is reading and 8 is appending
'-The "True" is to create if not already there.
Set fl = fso.OpenTextFile("C:\temp\textFile.txt", 2, True)
fl.Write(websiteText)
fl.Close : Set fl = Nothing
Set fso = Nothing
set WshShell = nothing
set http = nothing
The issue is, when I attempt it on a larger webpage, it fails, for what I assume to be too much text to handle. The website I am trying to rip the text off of is sometimes very large, so I am looking for a solution that isn't limited. I'm sure someone out that has had to accomplish this before.
The reason I am using VBS, is because I know VBS can access elements of a webpage, input fields, buttons, etc. Not sure if VBA can do that. I'm open to a VBA solution if it can accomplish logging into a webpage, stripping the data, and jamming it in Excel.
Any thoughts? Thanks in advance for any help.