Solved

Automate save as HTML for multiple URLs

Posted on 2015-02-21
6
45 Views
Last Modified: 2016-02-10
I have a list of 180 URLs all of which point to static web pages. I want to automate the task of saving each as an individual HTML file. Is this possible?
0
Comment
Question by:K_Deutsch
  • 3
  • 3
6 Comments
 
LVL 12

Expert Comment

by:FarWest
ID: 40623932
sure, you can make an excel sheet that contains URLs List, and destination HTML files name (or use formula to auto generate those names) and then run vba script like the one in this url
stackoverflow.com/questions/13193210/can-i-save-a-webpage-source-html-dynamically-using-vba-in-my-local-machine
 
but be aware that there is a glitch related to embedding images in the page, they will point to their original url
0
 

Author Comment

by:K_Deutsch
ID: 40624354
Sounds good and I did a test on a single web page, but I must confess I am clueless as to how to incorporate (into VBA) the multiple URL and file name data from my two Excel columns.

URL List
http://www.abc.com
http://www.def.com

Destination file name list
abc.html
def.html
0
 
LVL 12

Accepted Solution

by:
FarWest earned 500 total points
ID: 40624381
attached working sample
EE-Book1SaveWebUrl.xlsm
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:K_Deutsch
ID: 40624511
When I run your sample with my URLs I get a ERROR_WINHTTP_NAME_NOT_RESOLVED error (server name could not be resolved). However, going back to the link you posted to the stackoverflow earlier, if I use just one of my specific URLs (similar to what you see in bold below) it works.

We may have gotten outside of the original scope of this question.


Sub GetHTTP()
Dim objHttp As Object
Dim CachedFilePath As String
    Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
   Call objHttp.Open("GET", "http://www.abc.com/content/502", False)
    Call objHttp.Send("")
    CachedFilePath = Environ("temp") & "\" & "ReplaceThisWithFilename" & ".html"
    Call CreateFile(CachedFilePath, objHttp.ResponseText)
End Sub

Function CreateFile(FileName As String, Contents As String) As String
' creates file from string contents
Dim tempFile As String
Dim nextFileNum As Long
  nextFileNum = FreeFile
  tempFile = FileName
  Open tempFile For Output As #nextFileNum
  Print #nextFileNum, Contents
  Close #nextFileNum
  CreateFile = tempFile
End Function
0
 
LVL 12

Expert Comment

by:FarWest
ID: 40624592
Just in case use ltrim and rtrim  functions on the URL cell value
It maybe caused by spaces
I'm away from my computer. But it seems URL specific problem.
0
 

Author Comment

by:K_Deutsch
ID: 40624628
My list of URLs included the http://. Once I cut that out it works now. Thank you!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Surprisingly, there is a lot to Gym battles, and I thought it would be helpful to share knowledge about all the ins and outs of this feature!
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Notifications on Experts Exchange help you keep track of your activity and updates in one place. Watch this video to learn how to use them on the site to quickly access the content that matters to you.
Saved searches can save you time by quickly referencing commonly searched terms on any topic. Whether you are looking for questions you can answer or hoping to learn about a specific issue, a saved search can help you get the most out of your time o…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now