Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Automate save as HTML for multiple URLs

Posted on 2015-02-21
6
Medium Priority
?
62 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 total points
ID: 40624381
attached working sample
EE-Book1SaveWebUrl.xlsm
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding a job can be stressful - searches, resume tweaks, and networking events can be super boring. Luckily we're here to help you land your dream job!
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
Articles on a wide range of technology and professional topics are available on Experts Exchange. These resources are written by members, for members, and can be written about any topic you feel passionate about. Learn how to best write an article t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

688 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