Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Obtain Web Data dotNet .Net System.Net System.Net.WebRequest GetResponseSystem.Net.WebClient System.Text.Encoding ObjectClrNew GetResponseStream StreamReader ReadToEnd
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Obtain Web Data using System.Net.WebRequest ; ; Deana Falk 2013.04.29 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If Version( )< '2013A' Pause("Notice", "Need 2013A or Newer Version of WinBatch") Exit EndIf cURL="http://search.twitter.com/search.rss?q=WinBatch" ObjectClrOption("use","System.Net, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL") Encoding = ObjectClrNew( 'System.Text.Encoding' ) WebRequest = ObjectClrNew('System.Net.WebRequest') ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Initialize a new WebRequest instance for the specified URI scheme. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WebRequest = WebRequest.Create(cURL) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Set the 'Timeout' property in Milliseconds. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Pause("","The Timeout time of the request BEFORE setting is : ":WebRequest.Timeout:" milliseconds") WebRequest.Timeout = WebRequest.Timeout * 6 Pause("","The Timeout time of the request AFTER setting is : ":WebRequest.Timeout:" milliseconds") ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; GetResponse ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WebResponse = WebRequest.GetResponse() ;Pause("Content length is ", WebResponse.ContentLength) ;Pause("Content type is ", WebResponse.ContentType) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Get the stream associated with the response ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ResponseStream = WebResponse.GetResponseStream ; Pipes the stream to a higher level stream reader with the required encoding format. StreamReader = ObjectClrNew("System.IO.StreamReader", ResponseStream, Encoding.UTF8) Pause("", StreamReader.ReadToEnd()) Exit
;/////////////////////////////////////////////////////////////////////////////////////////////////////// ;Winbatch 2013A - Obtain Web Data using the CLR ; ;Stan Littlefield, April 29,2013 ;/////////////////////////////////////////////////////////////////////////////////////////////////////// If Version( )< '2013A' Pause("Notice", "Need 2013A or Newer Version of WinBatch") Exit EndIf ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Inputs ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;cURL="http://www.federalreserve.gov/releases/h10/update/h10daily.txt" cURL="http://search.twitter.com/search.rss?q=WinBatch" ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Load assembly into the WinBatch process ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ObjectClrOption("use","System.Net, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL") ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Create a class implemented by a managed assembly. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ WebClient = ObjectClrNew('System.Net.WebClient') ;Encoding = ObjectClrNew( 'System.Text.Encoding' ) ;WebClient.Encoding = Encoding.UTF8 cTxt = WebClient.DownloadString(cURL) Message("",cTxt) Exit ;///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Article ID: W17835
Filename: Obtain Web Data.txt
File Created: 2013:04:29:11:31:22
Last Updated: 2013:04:29:11:31:22