Created
April 15, 2018 18:20
-
-
Save gifguide2code/08b962dab584263214648875d5f9ca91 to your computer and use it in GitHub Desktop.
A VBA web scraper to bulk copy the HTML from http://www.imsdb.com/scripts/.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Scrape() | |
'Create an array of movie names | |
Dim Movies() | |
Movies = Array("Alien", "Avatar", "Blade-Runner", "Gattaca", "Ghostbusters", "Jurassic-Park", "Looper", "Lost-in-Space", "Sphere", "Signs", "Spider-Man", "Terminator", "V-for-Vendetta") | |
'Loop through each item in the movie array | |
For x = LBound(Movies) To UBound(Movies) | |
ActiveDocument.StoryRanges(wdMainTextStory).Delete | |
Script = "http://www.imsdb.com/scripts/" & Movies(x) & ".html" | |
Dim appIE As Object | |
Set appIE = CreateObject("InternetExplorer.Application") | |
With appIE | |
.Navigate Script | |
.Visible = True | |
End With | |
Do While appIE.Busy | |
DoEvents | |
Loop | |
ActiveDocument.Content.InsertAfter Text:=appIE.Document.body.innerHTML | |
On Error GoTo ErrorHandler | |
FilePath = "C:\Users\Desktop\Scripts\" & Movies(x) & ".doc" | |
ActiveDocument.SaveAs2 FilePath | |
appIE.Quit | |
'End Loop | |
Next x | |
ActiveDocument.Close | |
Application.Quit | |
ErrorHandler: | |
MsgBox Movies(x) & " could not be loaded." | |
Resume | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment