Winscripter
  WSH
  Forums
  Downloads
  Books
  Links
  Amazon




Login
Register

© winscripter.com
1998-2004







Script: Download a Web Page Using the Internet Transfer Control

Posted by on Sunday, January 18, 2004 (PST)

Script: Download a web page using Microsoft's Internet Transfer Control (InetCtls.Inet).
/** 
 *    Script:   dlwebpage.js
 *    Purpose:  Downloads the webpage specified by 'url'
 *    Author:   Daren Thiel
 *    Date:     17 May 1999
 *
 *    Note:     Rename this script dlwebpage.js
 *    Web:     
http://www.winscripter.com
 *              Copyright 1999 Daren Thiel
 **/
// The URL to download
var url = "http://www.winscripter.com/index.html"
// Create instance of Inet Control
inet = new ActiveXObject("InetCtls.Inet");
// Set the timeout property
inet.RequestTimeOut = 20;
// Set the URL property of the control
inet.Url = url;
// Actually download the file
var s = inet.OpenURL();
// Show the raw HTML to the user
WScript.Echo( s );
// Bonus - Find the title of the page
// Regular expression to find the string stored between
// the title tags.
rtitle = /<title>(.*)<\/title>/i;
// Execute the regular expression on the raw HTML
var title = rtitle.exec( s );
// Display the result
WScript.Echo( RegExp.$1 );
 

Comments:

Runtime licencing
By kiwicmc on Monday, April 04, 2005 (PST)
This works well and good on a machine that has a MS development tool installed. However when running on a machine without such tools. You first have to register the msinet.ocx with regsvr32, then you come to a problem with run-time licencing and the following error message: Class is not licensed for use Googling seems to imply that you cannot use this control outside of a VB application. Anyone got any ideas? Chris



WSH and ADSI Administrative Scripting

New Articles
  • List installed COM objects and associated ProgIDs
    Script: Lists all COM Objects and their associated ProgIDs (If available). Win32_ClassicCOMClassSetting

  • Script: File Rotator
    Script: Rotate files where the most current file has the lowest number in the archive. When files exceed the retention period, they are deleted. Typically used for log files, backups, etc..

  • Script: Create IIS Website and DNS record
    Script: Dan Casier sent me this script that will create a website and appropriate DNS record. The script is intended for Windows 2000 Server with local DNS and necessary DNS mof installed.


  • Winscripter   |  WSH   |  Forums   |  Downloads   |  Books   |  Links   |  Amazon