How to print multiple html files?

How can I print multiple html files located on web, and not on a local drive?

Something like:

  • http://www.domain.com/file.html?ID=1
  • http://www.domain.com/file.html?ID=2
  • http://www.domain.com/file.html?ID=3
  • http://www.domain.com/file.html?ID=4
  • ...
  • http://www.domain.com/file.html?ID=n

Can I create a batch file? Or is there a better approach to print about 500 html documents, each only different by ?ID=.


You can do it with Windows PowerShell (available natively on Windows 7, must be downloaded for Windows XP/Vista)

The quick and dirty script looks like this (you can paste it to a PowerShell window or save as a .ps1 file):

$ie = new-object -com InternetExplorer.Application
$ie.visible = $false
$url = "http://www.domain.com/file.html?ID="
For ($id=1; $id -le 500; $id++) {
  $ie.Navigate($url+$id.ToString())
  while ($ie.busy) {start-sleep -milliseconds 500}
  $ie.ExecWB(6,2)
}

This should work if your IDs really are sequential (from 1 to 500).

What it does:

  • Create an Internet Explorer instance (not visible)
  • Set the desired URL (minus the ID number at the end)
  • Loop throught all IDs from 1 to 500 and print them to your default printer (the $ie.ExecWB(6,2) line)