Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Fri, 13 Jun 2008 02:36:21 -0700 (PDT),    group: microsoft.public.inetsdk.programming.scripting.vbscript        back       


Using wininet over http to get a get.cgi file   
Hello, I want to access a projector over the network with a vb script
so I can read the lamp hours and status. Can someone help me with some
examples with wininet? I made a search (google as well as Microsoft)
but I can not get it in a vbscript.
date: Fri, 13 Jun 2008 02:36:21 -0700 (PDT)   author:   Skylan

Re: Using wininet over http to get a get.cgi file   
Il giorno Fri, 13 Jun 2008 02:36:21 -0700 (PDT), Skylan  ha
scritto:

>Hello, I want to access a projector over the network with a vb script
>so I can read the lamp hours and status. Can someone help me with some
>examples with wininet? I made a search (google as well as Microsoft)
>but I can not get it in a vbscript.

I use mshtml.

Sub DownloadWithXMLHTTP (sSource,sDest)
	'Download a file using activeX Object XMLHTTP
	'and save to sDest using ADO Stream
	set oHTTP = WScript.CreateObject("Microsoft.XMLHTTP")
	oHTTP.open "GET", sSource, False
	oHTTP.send
	set oStream = createobject("adodb.stream")
	Const adTypeBinary = 1
	Const adSaveCreateNotExist = 1
	Const adSaveCreateOverWrite = 2
	oStream.type = adTypeBinary
	oStream.open
	oStream.write oHTTP.responseBody
	oStream.savetofile sDest, adSaveCreateOverWrite
	set oStream = nothing
	set oHTTP = nothing
end sub

-- 
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
date: Mon, 16 Jun 2008 21:18:27 GMT   author:   (Reventlov)

Re: Using wininet over http to get a get.cgi file   
On Jun 16, 11:18 pm, no...@no.void (Reventlov) wrote:
> Il giorno Fri, 13 Jun 2008 02:36:21 -0700 (PDT), Skylan  ha
> scritto:
>
> >Hello, I want to access aprojectorover the network with avbscript
> >so I can read the lamp hours and status. Can someone help me with some
> >examples with wininet? I made a search (google as well as Microsoft)
> >but I can not get it in a vbscript.
>
> I use mshtml.
>
> Sub DownloadWithXMLHTTP (sSource,sDest)
>         'Download a file using activeX Object XMLHTTP
>         'and save to sDest using ADO Stream
>         set oHTTP = WScript.CreateObject("Microsoft.XMLHTTP")
>         oHTTP.open "GET", sSource, False
>         oHTTP.send
>         set oStream = createobject("adodb.stream")
>         Const adTypeBinary = 1
>         Const adSaveCreateNotExist = 1
>         Const adSaveCreateOverWrite = 2
>         oStream.type = adTypeBinary
>         oStream.open
>         oStream.write oHTTP.responseBody
>         oStream.savetofile sDest, adSaveCreateOverWrite
>         set oStream = nothing
>         set oHTTP = nothing
> end sub
>
> --
> Giovanni Cenati (Bergamo, Italy)
> Write to "Reventlov" at katamail comhttp://digilander.libero.it/Cenati(Esempi e programmi in VbScript)
> --

Due to lack of knowledge I cannot get any further. I want to create an
overview of all projectors in one screen. In this overview I can see
Lamp Runtimes, Lamp Remaining, Total operation and if the projector is
ON or OFF. Via http://192.168.200.1/info.cgi I can see it with the
Internet Explorer.

Can you put me in the right direction?
date: Wed, 18 Jun 2008 06:31:00 -0700 (PDT)   author:   Skylan

Re: Using wininet over http to get a get.cgi file   
Il giorno Wed, 18 Jun 2008 06:31:00 -0700 (PDT), Skylan  ha
scritto:

>Due to lack of knowledge I cannot get any further. I want to create an
>overview of all projectors in one screen. In this overview I can see
>Lamp Runtimes, Lamp Remaining, Total operation and if the projector is
>ON or OFF. Via http://192.168.200.1/info.cgi I can see it with the
>Internet Explorer.

DownloadWithXMLHTTP ("http://192.168.200.1/info.cgi","c:\temp.txt")

This creates the file c:\temp.txt containing the text returned from the cgi page. The same
you would have in ie but without images.
Then you have to parse the file in search of the information you need. You can parse the
file with any program in any language you know.
Giovanni.

-- 
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
date: Wed, 18 Jun 2008 21:59:21 GMT   author:   (Reventlov)

Re: Using wininet over http to get a get.cgi file   
On Jun 18, 11:59 pm, no...@no.void (Reventlov) wrote:
> Il giorno Wed, 18 Jun 2008 06:31:00 -0700 (PDT), Skylan  ha
> scritto:
>
> >Due to lack of knowledge I cannot get any further. I want to create an
> >overview of all projectors in one screen. In this overview I can see
> >Lamp Runtimes, Lamp Remaining, Total operation and if the projector is
> >ON or OFF. Viahttp://192.168.200.1/info.cgiI can see it with the
> >Internet Explorer.
>
> DownloadWithXMLHTTP ("http://192.168.200.1/info.cgi","c:\temp.txt")
>
> This creates the file c:\temp.txt containing the text returned from the cgi page. The same
> you would have in ie but without images.
> Then you have to parse the file in search of the information you need. You can parse the
> file with any program in any language you know.
> Giovanni.
>
> --
> Giovanni Cenati (Bergamo, Italy)
> Write to "Reventlov" at katamail comhttp://digilander.libero.it/Cenati(Esempi e programmi in VbScript)
> --

Thanks Giovanni, I'm back on track. ;-)
date: Thu, 19 Jun 2008 01:36:24 -0700 (PDT)   author:   Skylan

Re: Using wininet over http to get a get.cgi file   
"Skylan"  wrote in message 
news:b4a7b2e8-5878-416f-84e2-903beaab1dca@b1g2000hsg.googlegroups.com...
> On Jun 18, 11:59 pm, no...@no.void (Reventlov) wrote:
>> Il giorno Wed, 18 Jun 2008 06:31:00 -0700 (PDT), Skylan 
>>  ha
>> scritto:
>>
>> >Due to lack of knowledge I cannot get any further. I want to create an
>> >overview of all projectors in one screen. In this overview I can see
>> >Lamp Runtimes, Lamp Remaining, Total operation and if the projector is
>> >ON or OFF. Viahttp://192.168.200.1/info.cgiI can see it with the
>> >Internet Explorer.
>>
>> DownloadWithXMLHTTP ("http://192.168.200.1/info.cgi","c:\temp.txt")
>>
>> This creates the file c:\temp.txt containing the text returned from the 
>> cgi page. The same
>> you would have in ie but without images.
>> Then you have to parse the file in search of the information you need. 
>> You can parse the
>> file with any program in any language you know.
>> Giovanni.
>>
>> --
>> Giovanni Cenati (Bergamo, Italy)
>> Write to "Reventlov" at katamail 
>> comhttp://digilander.libero.it/Cenati(Esempi e programmi in VbScript)
>> --
>
> Thanks Giovanni, I'm back on track. ;-)
If you want to parse the file as an html document then you create a new 
"htmlfile" using:
set doc = CreateObject("htmlfile")

You can then document.write the HTML from the temp file into the doc and 
parse the contents using traditional dom methods.

-- 

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
date: Fri, 20 Jun 2008 08:41:13 +0100   author:   Joe Fawcett am

Re: Using wininet over http to get a get.cgi file   
On Jun 20, 9:41 am, "Joe Fawcett" <joefawc...@newsgroup.nospam> wrote:
> "Skylan"  wrote in message
>
> news:b4a7b2e8-5878-416f-84e2-903beaab1dca@b1g2000hsg.googlegroups.com...
>
>
>
> > On Jun 18, 11:59 pm, no...@no.void (Reventlov) wrote:
> >> Il giorno Wed, 18 Jun 2008 06:31:00 -0700 (PDT), Skylan
> >>  ha
> >> scritto:
>
> >> >Due to lack of knowledge I cannot get any further. I want to create an
> >> >overview of all projectors in one screen. In this overview I can see
> >> >Lamp Runtimes, Lamp Remaining, Total operation and if the projector is
> >> >ON or OFF. Viahttp://192.168.200.1/info.cgiIcan see it with the
> >> >Internet Explorer.
>
> >> DownloadWithXMLHTTP ("http://192.168.200.1/info.cgi","c:\temp.txt")
>
> >> This creates thefilec:\temp.txt containing the text returned from the
> >>cgipage. The same
> >> you would have in ie but without images.
> >> Then you have to parse thefilein search of the information you need.
> >> You can parse the
> >>filewith any program in any language you know.
> >> Giovanni.
>
> >> --
> >> Giovanni Cenati (Bergamo, Italy)
> >> Write to "Reventlov" at katamail
> >> comhttp://digilander.libero.it/Cenati(Esempie programmi in VbScript)
> >> --
>
> > Thanks Giovanni, I'm back on track. ;-)
>
> If you want to parse thefileas an html document then you create a new
> "htmlfile" using:
> set doc = CreateObject("htmlfile")
>
> You can then document.write the HTML from the tempfileinto the doc and
> parse the contents using traditional dom methods.
>
> --
>
> Joe Fawcett (MVP - XML)http://joe.fawcett.name- Hide quoted text -
>
> - Show quoted text -

From the info.cgi file, I only need the fields like "LAMP
RUNTIME" (value: 585 H) and "POWER" (value: ON). How can I delete all
<codes>?
Sample code:

<TD width="100%" class="monitor_table_property"><TABLE border="0"
cellSpacing="0" width="100%"><TR><TD width="330" align="left"
class="monitor_table_property">  <b>LAMP RUNTIME</b></TD><TD
align="right" width="120" class="monitor_table_property"><font
color="#00ff12"><b>585 H</b>    </font></TD><TD
width="250" class="monitor_table_property"><center><TABLE border="0"
width="100%" cellSpacing="0" cellPadding="0"><TR><TD nowrap
width="19%" height="15" bgcolor="#00ff12"></TD><TD nowrap width="81height="15" bgcolor="#000000"></TD>
date: Mon, 23 Jun 2008 12:00:29 -0700 (PDT)   author:   Skylan

Re: Using wininet over http to get a get.cgi file   
>> If you want to parse thefileas an html document then you create a new
>> "htmlfile" using:
>> set doc = CreateObject("htmlfile")
>>
>> You can then document.write the HTML from the tempfileinto the doc and
>> parse the contents using traditional dom methods.
>>
>> --
>>
>> Joe Fawcett (MVP - XML)http://joe.fawcett.name- Hide quoted text -
>>
>> - Show quoted text -
>
> From the info.cgi file, I only need the fields like "LAMP
> RUNTIME" (value: 585 H) and "POWER" (value: ON). How can I delete all
> <codes>?
> Sample code:
>
> <TD width="100%" class="monitor_table_property"><TABLE border="0"
> cellSpacing="0" width="100%"><TR><TD width="330" align="left"
> class="monitor_table_property">  <b>LAMP RUNTIME</b></TD><TD
> align="right" width="120" class="monitor_table_property"><font
> color="#00ff12"><b>585 H</b>    </font></TD><TD
> width="250" class="monitor_table_property"><center><TABLE border="0"
> width="100%" cellSpacing="0" cellPadding="0"><TR><TD nowrap
> width="19%" height="15" bgcolor="#00ff12"></TD><TD nowrap width="81%"
> height="15" bgcolor="#000000"></TD>
>

Example script:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit

Dim sData
sData = "<TD width=""100%"" class=""monitor_table_property""><TABLE 
border=""0""" & _
        "cellSpacing=""0"" width=""100%""><TR><TD width=""330"" 
align=""left""" & _
        "class=""monitor_table_property"">  <b>LAMP 
RUNTIME</b></TD><TD "  & _
        "align=""right"" width=""120"" 
class=""monitor_table_property""><font"  & _
        "color=""#00ff12""><b>585 
H</b>    </font></TD><TD"  & _
        "width=""250"" class=""monitor_table_property""><center><TABLE 
border=""0"""  & _
        "width=""100%"" cellSpacing=""0"" cellPadding=""0""><TR><TD nowrap" 
& _
        "width=""19%"" height=""15"" bgcolor=""#00ff12""></TD><TD nowrap 
width=""81%"""  & _
        "height=""15"" bgcolor=""#000000""></TD>"

Private Function FixHtml(data)
  Dim sHtml
  sHtml = "<html><body><table><tr>" & data & "</tr></table></body></html>"
  FixHtml = sHtml
End Function

Private Function GetHtmlDoc(html)
  Dim oDoc
  Set oDoc = CreateObject("htmlfile")
  oDoc.open
  oDoc.write html
  oDoc.close
  Set GetHtmlDoc = oDoc
End Function

Public Sub Main()
  'WScript.Echo sData
  Dim sHtml
  sHtml = FixHtml(sData)
  'WScript.Echo(sHtml)
  Dim oDoc
  Set oDoc = GetHtmlDoc(sHtml)
  'WScript.echo oDoc.body.innerHTML
  Dim oTable
  Set oTable = oDoc.GetElementsByTagName("table")(1)
  Dim oCell
  Set oCell = oTable.Rows(0).Cells(1)
  'WScript.echo oCell.innerHTML
  Dim oBold
  Set oBold = oCell.GetElementsByTagName("b")(0)
  WScript.echo oBold.innerHTML
End Sub

Call Main()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

-- 

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
date: Thu, 26 Jun 2008 09:28:00 +0100   author:   Joe Fawcett am

Re: Using wininet over http to get a get.cgi file   
On Jun 26, 10:28 am, "Joe Fawcett" <joefawc...@newsgroup.nospam>
wrote:
> >> If you want to parse thefileas an html document then you create a new
> >> "htmlfile" using:
> >> set doc = CreateObject("htmlfile")
>
> >> You can then document.write the HTML from the tempfileinto the doc and
> >> parse the contents using traditional dom methods.
>
> >> --
>
> >> Joe Fawcett (MVP - XML)http://joe.fawcett.name-Hide quoted text -
>
> >> - Show quoted text -
>
> > From the info.cgi file, I only need the fields like "LAMP
> > RUNTIME" (value: 585 H) and "POWER" (value: ON). How can I delete all
> > <codes>?
> > Sample code:
>
> > <TD width="100%" class="monitor_table_property"><TABLE border="0"
> > cellSpacing="0" width="100%"><TR><TD width="330" align="left"
> > class="monitor_table_property">  <b>LAMP RUNTIME</b></TD><TD
> > align="right" width="120" class="monitor_table_property"><font
> > color="#00ff12"><b>585 H</b>    </font></TD><TD
> > width="250" class="monitor_table_property"><center><TABLE border="0"
> > width="100%" cellSpacing="0" cellPadding="0"><TR><TD nowrap
> > width="19%" height="15" bgcolor="#00ff12"></TD><TD nowrap width="81%"
> > height="15" bgcolor="#000000"></TD>
>
> Example script:
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''­'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''­'''''''''''''
>
> Option Explicit
>
> Dim sData
> sData = "<TD width=""100%"" class=""monitor_table_property""><TABLE
> border=""0""" & _
>         "cellSpacing=""0"" width=""100%""><TR><TD width=""330""
> align=""left""" & _
>         "class=""monitor_table_property"">  <b>LAMP
> RUNTIME</b></TD><TD "  & _
>         "align=""right"" width=""120""
> class=""monitor_table_property""><font"  & _
>         "color=""#00ff12""><b>585
> H</b>    </font></TD><TD"  & _
>         "width=""250"" class=""monitor_table_property""><center><TABLE
> border=""0"""  & _
>         "width=""100%"" cellSpacing=""0"" cellPadding=""0""><TR><TD nowrap"
> & _
>         "width=""19%"" height=""15"" bgcolor=""#00ff12""></TD><TD nowrap
> width=""81%"""  & _
>         "height=""15"" bgcolor=""#000000""></TD>"
>
> Private Function FixHtml(data)
>   Dim sHtml
>   sHtml = "<html><body><table><tr>" & data & "</tr></table></body></html>"
>   FixHtml = sHtml
> End Function
>
> Private Function GetHtmlDoc(html)
>   Dim oDoc
>   Set oDoc = CreateObject("htmlfile")
>   oDoc.open
>   oDoc.write html
>   oDoc.close
>   Set GetHtmlDoc = oDoc
> End Function
>
> Public Sub Main()
>   'WScript.Echo sData
>   Dim sHtml
>   sHtml = FixHtml(sData)
>   'WScript.Echo(sHtml)
>   Dim oDoc
>   Set oDoc = GetHtmlDoc(sHtml)
>   'WScript.echo oDoc.body.innerHTML
>   Dim oTable
>   Set oTable = oDoc.GetElementsByTagName("table")(1)
>   Dim oCell
>   Set oCell = oTable.Rows(0).Cells(1)
>   'WScript.echo oCell.innerHTML
>   Dim oBold
>   Set oBold = oCell.GetElementsByTagName("b")(0)
>   WScript.echo oBold.innerHTML
> End Sub
>
> Call Main()
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''­'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''­''''''
>
> --
>
> Joe Fawcett (MVP - XML)http://joe.fawcett.name- Hide quoted text -
>
> - Show quoted text -

This looks nice, and is a step forward. But can you do this from a
text file (or html)? Because I have downloaded the cgi file to text
from all projectors and saved this on my disk in projector specific
folder. Afterwards I want the data out of the file into a 'table' with
all the lamp hours. We have over 30 beamers which we have to support.
If I can see all beamers at one time that would be great. The cgi
files are different per projector (different type and vendor).
date: Fri, 27 Jun 2008 07:01:07 -0700 (PDT)   author:   Skylan

Re: Using wininet over http to get a get.cgi file   
"Skylan"  wrote in message 
news:6ff99496-d13a-43ac-8b74-cbd44a8b56e7@k30g2000hse.googlegroups.com...
> On Jun 26, 10:28 am, "Joe Fawcett" <joefawc...@newsgroup.nospam>
> wrote:
>> >> If you want to parse thefileas an html document then you create a new
>> >> "htmlfile" using:
>> >> set doc = CreateObject("htmlfile")
>>
>> >> You can then document.write the HTML from the tempfileinto the doc and
>> >> parse the contents using traditional dom methods.
>>
>> >> --
>>
>> >> Joe Fawcett (MVP - XML)http://joe.fawcett.name-Hide quoted text -
>>
>> >> - Show quoted text -
>>
>> > From the info.cgi file, I only need the fields like "LAMP
>> > RUNTIME" (value: 585 H) and "POWER" (value: ON). How can I delete all
>> > <codes>?
>> > Sample code:
>>
>> > <TD width="100%" class="monitor_table_property"><TABLE border="0"
>> > cellSpacing="0" width="100%"><TR><TD width="330" align="left"
>> > class="monitor_table_property">  <b>LAMP RUNTIME</b></TD><TD
>> > align="right" width="120" class="monitor_table_property"><font
>> > color="#00ff12"><b>585 H</b>    </font></TD><TD
>> > width="250" class="monitor_table_property"><center><TABLE border="0"
>> > width="100%" cellSpacing="0" cellPadding="0"><TR><TD nowrap
>> > width="19%" height="15" bgcolor="#00ff12"></TD><TD nowrap width="81%"
>> > height="15" bgcolor="#000000"></TD>
>>
>> Example script:
>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''­'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''­'''''''''''''
>>
>> Option Explicit
>>
>> Dim sData
>> sData = "<TD width=""100%"" class=""monitor_table_property""><TABLE
>> border=""0""" & _
>> "cellSpacing=""0"" width=""100%""><TR><TD width=""330""
>> align=""left""" & _
>> "class=""monitor_table_property"">  <b>LAMP
>> RUNTIME</b></TD><TD " & _
>> "align=""right"" width=""120""
>> class=""monitor_table_property""><font" & _
>> "color=""#00ff12""><b>585
>> H</b>    </font></TD><TD" & _
>> "width=""250"" class=""monitor_table_property""><center><TABLE
>> border=""0""" & _
>> "width=""100%"" cellSpacing=""0"" cellPadding=""0""><TR><TD nowrap"
>> & _
>> "width=""19%"" height=""15"" bgcolor=""#00ff12""></TD><TD nowrap
>> width=""81%""" & _
>> "height=""15"" bgcolor=""#000000""></TD>"
>>
>> Private Function FixHtml(data)
>> Dim sHtml
>> sHtml = "<html><body><table><tr>" & data & "</tr></table></body></html>"
>> FixHtml = sHtml
>> End Function
>>
>> Private Function GetHtmlDoc(html)
>> Dim oDoc
>> Set oDoc = CreateObject("htmlfile")
>> oDoc.open
>> oDoc.write html
>> oDoc.close
>> Set GetHtmlDoc = oDoc
>> End Function
>>
>> Public Sub Main()
>> 'WScript.Echo sData
>> Dim sHtml
>> sHtml = FixHtml(sData)
>> 'WScript.Echo(sHtml)
>> Dim oDoc
>> Set oDoc = GetHtmlDoc(sHtml)
>> 'WScript.echo oDoc.body.innerHTML
>> Dim oTable
>> Set oTable = oDoc.GetElementsByTagName("table")(1)
>> Dim oCell
>> Set oCell = oTable.Rows(0).Cells(1)
>> 'WScript.echo oCell.innerHTML
>> Dim oBold
>> Set oBold = oCell.GetElementsByTagName("b")(0)
>> WScript.echo oBold.innerHTML
>> End Sub
>>
>> Call Main()
>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''­'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''­''''''
>>
>> --
>>
>> Joe Fawcett (MVP - XML)http://joe.fawcett.name- Hide quoted text -
>>
>> - Show quoted text -
>
> This looks nice, and is a step forward. But can you do this from a
> text file (or html)? Because I have downloaded the cgi file to text
> from all projectors and saved this on my disk in projector specific
> folder. Afterwards I want the data out of the file into a 'table' with
> all the lamp hours. We have over 30 beamers which we have to support.
> If I can see all beamers at one time that would be great. The cgi
> files are different per projector (different type and vendor).

Yes, you can open each file using FileSystemObject and use the data in the 
file as above.
Alternatively as they are already on the drive you could automate IE and 
read the data that way.

-- 

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
date: Sat, 28 Jun 2008 10:16:56 +0100   author:   Joe Fawcett am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us