Thursday, June 14, 2012



Here is a vbscript / vbs / vb script example which collects hebrew results from an External Website (Google Results in Example):

Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
Set FSO = createobject("Scripting.FileSystemObject")

'Define Some http headers and options
 strUserAgentString = "http_requester/0.1"
 intSslErrorIgnoreFlags = 13056 ' 13056: ignore all err, 0: accept no err
 blnEnableRedirects = True
 blnEnableHttpsToHttpRedirects = True
   
  objWinHttp.Option(0) = strUserAgentString
  objWinHttp.Option(4) = intSslErrorIgnoreFlags
  objWinHttp.Option(6) = blnEnableRedirects
  objWinHttp.Option(12) = blnEnableHttpsToHttpRedirects

'If you need a Proxy define it here 
objWinHttp.SetProxy 2,"148.87.65.20:80"

'Define the Hebrew Google String you would like or any other Hebrew website.
URL = "https://www.google.co.il/search?sugexp=chrome,mod=3&sourceid=chrome&ie=UTF-8&q=%D7%99%D7%A9%D7%A8%D7%90%D7%9C"
objWinHttp.open "GET",URL
objWinHttp.setRequestHeader "Content-Type", "text/html; charset=UTF-8"
objWinHttp.send ""

'Generate an output file - This will fix UTF8 of objWinHttp.responseText to a file.
Set Fileout = FSO.CreateTextFile("c:\temp\google_utf8.xml", true, true)
Fileout.Write objWinHttp.responsetext
Fileout.Close

'Instead of using : 'WScript.Echo objWinHttp.responseText

How to implement :
Simply run it from CMD (windows)

ALL INFO APPEARS HERE THANKS TO :
http://www.tech-archive.net/Archive/Scripting/microsoft.public.scripting.vbscript/2007-04/msg00387.html


0 Comments:

Post a Comment