none
HTML vbscript Open and Close Page one at a time while going through multiple web pages.

Answers

  • Ok. Here is it:
    on error resume next  
    Dim WebPage(40)     
      WebPage(0) = "http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true"      
      WebPage(1) = "http://www.microsoft.com/technet/scriptcenter/resources/qanda/hsgarch.mspx"    
      WebPage(2) = "http://www.microsoft.com/technet/scriptcenter/default.mspx"    
      WebPage(3) = "www.nesn.com"    
      WebPage(4) = "www.foxsports.com"    
      WebPage(5) = "www.boston.com"    
      WebPage(6) = "www.espn.com"    
      WebPage(7) = "www.cnn.com"    
      WebPage(8) = "www.weather.com"    
      WebPage(9) = "www.abc.com"    
      WebPage(10) = "www.cbs.sportsline.com"    
      WebPage(11) = "www.msnbc.com"    
      WebPage(12) = "www.wmur.com"    
      WebPage(13) = "www.cbs.com"    
      WebPage(14) = "www.mlb.com"    
      WebPage(15) = "www.enterasys.com"    
      WebPage(16) = "www.nbc.com"    
      WebPage(17) = "www.wzlx.com"    
      WebPage(18) = "www.space.com"    
      WebPage(19) = "www.nepatriots.com"    
      WebPage(20) = "www.nyse.com"    
      WebPage(21) = "www.tvguide.com"    
      WebPage(22) = "www.nfl.com"    
      WebPage(23) = "www.nba.com"    
      WebPage(24) = "www.microsoft.com"    
      WebPage(25) = "www.moneycentral.msn.com/investor/market/home.aspx?pkw=stock&vendor=google&ocid=iSEMGoogle&refcd=go206675s_stock&tsacr=go558918480"    
      WebPage(26) = "www.usatoday.com"    
      WebPage(27) = "www.rock101fm.com"    
      WebPage(28) = "www.whdh.com"    
      WebPage(29) = "www.sports.yahoo.com"    
      WebPage(30) = "www.bostonredsox.com"    
      WebPage(31) = "www.wbz.com"    
      WebPage(32) = "www.wzid.com"    
      WebPage(33) = "www.myfoxboston.com"    
      WebPage(34) = "www.nasa.gov"    
      WebPage(35) = "www.nasdaq.com"    
      WebPage(36) = "www.bostonceltics.com"    
      WebPage(37) = "www.movietickets.com"    
      WebPage(38) = "www.noaa.com"    
      WebPage(39) = "www.theremyreport.com"    
          
      waitTime= 5000 'wait period in milliseconds     
    ' ------------------------------------------------------------------------------ '     
    ' Start Main loop'     
    i = 0     
    do     
      ' Initialize IE'     
      Set objExplorer = CreateObject("InternetExplorer.Application")           
      'objExplorer.AddressBar = 1      
      'objExplorer.Toolbar = 1      
      'objExplorer.StatusBar = 1      
      'objExplorer.Width = 600      
      'objExplorer.Height = 400      
      'objExplorer.Left = 300      
      'objExplorer.Top = 150      
        
      ' load next page     
      objExplorer.Navigate WebPage(i)   
        
      ' wait while loading      
      Do Until (objExplorer.readyState = 4)     
        wscript.sleep 100     
      Loop       
        
      ' Show finnaly      
      objExplorer.Visible = 1  
               
      ' wait period'     
      wscript.sleep waitTime     
           
        
      ' close IE  
      objExplorer.Quit  
        
      ' check our loop     
      i = i + 1     
      if i = 40 then     
        i = 0     
      end if     
    loop     
     
    Wednesday, December 17, 2008 8:19 AM
  • ScottG14 said:

    Aleksey,
    That is perfect.  Acouple of Questions.
    1.  In the script what does this function mean with the ReadyState = 4

    ' wait while loading      
      Do Until (objExplorer.readyState = 4)     
        wscript.sleep 100     



     This mean check every 0.1 sec (wscript.sleep 100) if IExplorer is finished loading page (objExplorer.readyState = 4)

    ScottG14 said:

    Aleksey,
    That is perfect.  Acouple of Questions.

    2.  If I change i = i  + 5 will that make it so that it would open internet explorer then go through 5 web pages then close internet explorer then let it do the next 5 and so on continuously?

    ' check our loop     
      i = i + 1     
      if i = 40 then     
        i = 0     
      end if     
    loop     

    Thanks for all your help.  This is a big help.
    Scott
    Skier

    No. I Variable is just counter to loop for all pages. If you assign not i = i + 1 but i = i + 5 this means that display every 5 page. In other words WebPage(0) then WebPage(4) then WebPage(9) etc.

    To do as you say use this modefied script:
    1 on error resume next     
    2 Dim WebPage(40)        
    3   WebPage(0) = "http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true"         
    4   WebPage(1) = "http://www.microsoft.com/technet/scriptcenter/resources/qanda/hsgarch.mspx"       
    5   WebPage(2) = "http://www.microsoft.com/technet/scriptcenter/default.mspx"       
    6   WebPage(3) = "www.nesn.com"       
    7   WebPage(4) = "www.foxsports.com"       
    8   WebPage(5) = "www.boston.com"       
    9   WebPage(6) = "www.espn.com"       
    10   WebPage(7) = "www.cnn.com"       
    11   WebPage(8) = "www.weather.com"       
    12   WebPage(9) = "www.abc.com"       
    13   WebPage(10) = "www.cbs.sportsline.com"       
    14   WebPage(11) = "www.msnbc.com"       
    15   WebPage(12) = "www.wmur.com"       
    16   WebPage(13) = "www.cbs.com"       
    17   WebPage(14) = "www.mlb.com"       
    18   WebPage(15) = "www.enterasys.com"       
    19   WebPage(16) = "www.nbc.com"       
    20   WebPage(17) = "www.wzlx.com"       
    21   WebPage(18) = "www.space.com"       
    22   WebPage(19) = "www.nepatriots.com"       
    23   WebPage(20) = "www.nyse.com"       
    24   WebPage(21) = "www.tvguide.com"       
    25   WebPage(22) = "www.nfl.com"       
    26   WebPage(23) = "www.nba.com"       
    27   WebPage(24) = "www.microsoft.com"       
    28   WebPage(25) = "www.moneycentral.msn.com/investor/market/home.aspx?pkw=stock&vendor=google&ocid=iSEMGoogle&refcd=go206675s_stock&tsacr=go558918480"       
    29   WebPage(26) = "www.usatoday.com"       
    30   WebPage(27) = "www.rock101fm.com"       
    31   WebPage(28) = "www.whdh.com"       
    32   WebPage(29) = "www.sports.yahoo.com"       
    33   WebPage(30) = "www.bostonredsox.com"       
    34   WebPage(31) = "www.wbz.com"       
    35   WebPage(32) = "www.wzid.com"       
    36   WebPage(33) = "www.myfoxboston.com"       
    37   WebPage(34) = "www.nasa.gov"       
    38   WebPage(35) = "www.nasdaq.com"       
    39   WebPage(36) = "www.bostonceltics.com"       
    40   WebPage(37) = "www.movietickets.com"       
    41   WebPage(38) = "www.noaa.com"       
    42   WebPage(39) = "www.theremyreport.com"       
    43     
    44 dim CurrentPageNubmer  
    45 dim PageToShowInClip  
    46 dim WaitTimeAfterpageLoaded       
    47           
    48 ' ------------------------------------------------------------------------------ '        
    49 ' Start Main loop'  
    50  
    51 ' Initialize variables'        
    52 CurrentPageNubmer = 0 ' counter, that display current page number'  
    53 CurrentClipPageNubmer = 0 ' counter, that display current page number in Clip'  
    54  
    55 PageToShowInClip = 5 ' Count of page to show in clip, then close IE window'  
    56  
    57 WaitTimeAfterpageLoaded= 5000 'wait period in milliseconds between pages        
    58 WaitTimeAfterClipLoaded= 10000 'wait period in milliseconds between single clips  
    59 do        
    60   ' Initialize IE'        
    61   Set objExplorer = CreateObject("InternetExplorer.Application")                    
    62     
    63   do while CurrentClipPageNubmer < PageToShowInClip  
    64     ' Display CurrentPage  
    65     ShowPage (WebPage(CurrentPageNubmer))  
    66       
    67     ' add counter  
    68     CurrentClipPageNubmer = CurrentClipPageNubmer + 1  
    69       
    70     ' check our loop         
    71     CurrentPageNubmer = CurrentPageNubmer + 1        
    72     if CurrentPageNubmer = 40 then        
    73       CurrentPageNubmer = 0        
    74     end if      
    75   loop    
    76   ' Reset page clip counter'  
    77   CurrentClipPageNubmer = 0   
    78     
    79   ' close IE      
    80   objExplorer.Quit    
    81     
    82   'wait for next clip  
    83   wscript.sleep WaitTimeAfterClipLoaded            
    84 loop    
    85  
    86 ' ------------------------------------------------------------------------------ '  
    87 ' ------------------------------------------------------------------------------ '  
    88 function ShowPage (URL)  
    89   ' load page        
    90   objExplorer.Navigate URL      
    91        
    92   ' wait while loading         
    93   Do Until (objExplorer.readyState = 4)        
    94     wscript.sleep 100        
    95   Loop          
    96        
    97   ' Show finnaly         
    98   objExplorer.Visible = 1     
    99               
    100   ' wait period'        
    101   wscript.sleep WaitTimeAfterpageLoaded     
    102 end function  
    103  
    104  
    105
    106

    ScottG14 said:

    Aleksey,
    When I run the script I am seeing this error.  Any Ideas Why?  I am running the script on Windows XP from the actually machine not from a remote server.
    Windows Script Host 
     Script:  
     C:\Documents and settings\pwa2.8021X\Desktop\MasterScript.vbs
    Line: 49
    Char: 3
    Error:  The remote server machine does not exist or is unavailable "CreateObject'
    Code 800A01CE
    Source Microsoft VBScript runtime error
    Thanks
    Scott


    Skier



    May be because of corp policy, that evaluate any scripts or etc. If scrip is runing on your local pc, this means it could run or any other if no corporate (domain) policy restrict's its

    Friday, December 19, 2008 8:18 AM

All replies

  • Hi! I'm try with script on IE8 beta 2, and it's work fine (due to 1 hour and with other url's)...
    see code in next post
    Tuesday, December 16, 2008 9:35 AM
  • Alesky,
    That isn't what I want the script to do.  What I want the script to do is to open Internet Explorer and goto Web Page (0),
    Then close Internet Explorer.   Next the script will reopen internet explorer and go to WebPage(1).  Then Close Internet Explorer and continue through this process going and opening and closing all 40 web pages.  Then start over with WebPage (0) and do this continuously.
    Thanks
    Scott
    Skier
    Tuesday, December 16, 2008 7:44 PM
  • Ok. Here is it:
    on error resume next  
    Dim WebPage(40)     
      WebPage(0) = "http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true"      
      WebPage(1) = "http://www.microsoft.com/technet/scriptcenter/resources/qanda/hsgarch.mspx"    
      WebPage(2) = "http://www.microsoft.com/technet/scriptcenter/default.mspx"    
      WebPage(3) = "www.nesn.com"    
      WebPage(4) = "www.foxsports.com"    
      WebPage(5) = "www.boston.com"    
      WebPage(6) = "www.espn.com"    
      WebPage(7) = "www.cnn.com"    
      WebPage(8) = "www.weather.com"    
      WebPage(9) = "www.abc.com"    
      WebPage(10) = "www.cbs.sportsline.com"    
      WebPage(11) = "www.msnbc.com"    
      WebPage(12) = "www.wmur.com"    
      WebPage(13) = "www.cbs.com"    
      WebPage(14) = "www.mlb.com"    
      WebPage(15) = "www.enterasys.com"    
      WebPage(16) = "www.nbc.com"    
      WebPage(17) = "www.wzlx.com"    
      WebPage(18) = "www.space.com"    
      WebPage(19) = "www.nepatriots.com"    
      WebPage(20) = "www.nyse.com"    
      WebPage(21) = "www.tvguide.com"    
      WebPage(22) = "www.nfl.com"    
      WebPage(23) = "www.nba.com"    
      WebPage(24) = "www.microsoft.com"    
      WebPage(25) = "www.moneycentral.msn.com/investor/market/home.aspx?pkw=stock&vendor=google&ocid=iSEMGoogle&refcd=go206675s_stock&tsacr=go558918480"    
      WebPage(26) = "www.usatoday.com"    
      WebPage(27) = "www.rock101fm.com"    
      WebPage(28) = "www.whdh.com"    
      WebPage(29) = "www.sports.yahoo.com"    
      WebPage(30) = "www.bostonredsox.com"    
      WebPage(31) = "www.wbz.com"    
      WebPage(32) = "www.wzid.com"    
      WebPage(33) = "www.myfoxboston.com"    
      WebPage(34) = "www.nasa.gov"    
      WebPage(35) = "www.nasdaq.com"    
      WebPage(36) = "www.bostonceltics.com"    
      WebPage(37) = "www.movietickets.com"    
      WebPage(38) = "www.noaa.com"    
      WebPage(39) = "www.theremyreport.com"    
          
      waitTime= 5000 'wait period in milliseconds     
    ' ------------------------------------------------------------------------------ '     
    ' Start Main loop'     
    i = 0     
    do     
      ' Initialize IE'     
      Set objExplorer = CreateObject("InternetExplorer.Application")           
      'objExplorer.AddressBar = 1      
      'objExplorer.Toolbar = 1      
      'objExplorer.StatusBar = 1      
      'objExplorer.Width = 600      
      'objExplorer.Height = 400      
      'objExplorer.Left = 300      
      'objExplorer.Top = 150      
        
      ' load next page     
      objExplorer.Navigate WebPage(i)   
        
      ' wait while loading      
      Do Until (objExplorer.readyState = 4)     
        wscript.sleep 100     
      Loop       
        
      ' Show finnaly      
      objExplorer.Visible = 1  
               
      ' wait period'     
      wscript.sleep waitTime     
           
        
      ' close IE  
      objExplorer.Quit  
        
      ' check our loop     
      i = i + 1     
      if i = 40 then     
        i = 0     
      end if     
    loop     
     
    Wednesday, December 17, 2008 8:19 AM
  • Aleksey,
    That is perfect.  Acouple of Questions.
    1.  In the script what does this function mean with the ReadyState = 4
    ' wait while loading      
      Do Until (objExplorer.readyState = 4)     
        wscript.sleep 100     

    2.  If I change i = i  + 5 will that make it so that it would open internet explorer then go through 5 web pages then close internet explorer then let it do the next 5 and so on continuously?
    ' check our loop     
      i = i + 1     
      if i = 40 then     
        i = 0     
      end if     
    loop     

    Thanks for all your help.  This is a big help.
    Scott

    Skier
    Wednesday, December 17, 2008 2:54 PM
  • Aleksey,
    When I run the script I am seeing this error.  Any Ideas Why?  I am running the script on Windows XP from the actually machine not from a remote server.
    Windows Script Host 
     Script:  
     C:\Documents and settings\pwa2.8021X\Desktop\MasterScript.vbs
    Line: 49
    Char: 3
    Error:  The remote server machine does not exist or is unavailable "CreateObject'
    Code 800A01CE
    Source Microsoft VBScript runtime error
    Thanks
    Scott
    Skier
    Wednesday, December 17, 2008 6:23 PM
  • ScottG14 said:

    Aleksey,
    That is perfect.  Acouple of Questions.
    1.  In the script what does this function mean with the ReadyState = 4

    ' wait while loading      
      Do Until (objExplorer.readyState = 4)     
        wscript.sleep 100     



     This mean check every 0.1 sec (wscript.sleep 100) if IExplorer is finished loading page (objExplorer.readyState = 4)

    ScottG14 said:

    Aleksey,
    That is perfect.  Acouple of Questions.

    2.  If I change i = i  + 5 will that make it so that it would open internet explorer then go through 5 web pages then close internet explorer then let it do the next 5 and so on continuously?

    ' check our loop     
      i = i + 1     
      if i = 40 then     
        i = 0     
      end if     
    loop     

    Thanks for all your help.  This is a big help.
    Scott
    Skier

    No. I Variable is just counter to loop for all pages. If you assign not i = i + 1 but i = i + 5 this means that display every 5 page. In other words WebPage(0) then WebPage(4) then WebPage(9) etc.

    To do as you say use this modefied script:
    1 on error resume next     
    2 Dim WebPage(40)        
    3   WebPage(0) = "http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true"         
    4   WebPage(1) = "http://www.microsoft.com/technet/scriptcenter/resources/qanda/hsgarch.mspx"       
    5   WebPage(2) = "http://www.microsoft.com/technet/scriptcenter/default.mspx"       
    6   WebPage(3) = "www.nesn.com"       
    7   WebPage(4) = "www.foxsports.com"       
    8   WebPage(5) = "www.boston.com"       
    9   WebPage(6) = "www.espn.com"       
    10   WebPage(7) = "www.cnn.com"       
    11   WebPage(8) = "www.weather.com"       
    12   WebPage(9) = "www.abc.com"       
    13   WebPage(10) = "www.cbs.sportsline.com"       
    14   WebPage(11) = "www.msnbc.com"       
    15   WebPage(12) = "www.wmur.com"       
    16   WebPage(13) = "www.cbs.com"       
    17   WebPage(14) = "www.mlb.com"       
    18   WebPage(15) = "www.enterasys.com"       
    19   WebPage(16) = "www.nbc.com"       
    20   WebPage(17) = "www.wzlx.com"       
    21   WebPage(18) = "www.space.com"       
    22   WebPage(19) = "www.nepatriots.com"       
    23   WebPage(20) = "www.nyse.com"       
    24   WebPage(21) = "www.tvguide.com"       
    25   WebPage(22) = "www.nfl.com"       
    26   WebPage(23) = "www.nba.com"       
    27   WebPage(24) = "www.microsoft.com"       
    28   WebPage(25) = "www.moneycentral.msn.com/investor/market/home.aspx?pkw=stock&vendor=google&ocid=iSEMGoogle&refcd=go206675s_stock&tsacr=go558918480"       
    29   WebPage(26) = "www.usatoday.com"       
    30   WebPage(27) = "www.rock101fm.com"       
    31   WebPage(28) = "www.whdh.com"       
    32   WebPage(29) = "www.sports.yahoo.com"       
    33   WebPage(30) = "www.bostonredsox.com"       
    34   WebPage(31) = "www.wbz.com"       
    35   WebPage(32) = "www.wzid.com"       
    36   WebPage(33) = "www.myfoxboston.com"       
    37   WebPage(34) = "www.nasa.gov"       
    38   WebPage(35) = "www.nasdaq.com"       
    39   WebPage(36) = "www.bostonceltics.com"       
    40   WebPage(37) = "www.movietickets.com"       
    41   WebPage(38) = "www.noaa.com"       
    42   WebPage(39) = "www.theremyreport.com"       
    43     
    44 dim CurrentPageNubmer  
    45 dim PageToShowInClip  
    46 dim WaitTimeAfterpageLoaded       
    47           
    48 ' ------------------------------------------------------------------------------ '        
    49 ' Start Main loop'  
    50  
    51 ' Initialize variables'        
    52 CurrentPageNubmer = 0 ' counter, that display current page number'  
    53 CurrentClipPageNubmer = 0 ' counter, that display current page number in Clip'  
    54  
    55 PageToShowInClip = 5 ' Count of page to show in clip, then close IE window'  
    56  
    57 WaitTimeAfterpageLoaded= 5000 'wait period in milliseconds between pages        
    58 WaitTimeAfterClipLoaded= 10000 'wait period in milliseconds between single clips  
    59 do        
    60   ' Initialize IE'        
    61   Set objExplorer = CreateObject("InternetExplorer.Application")                    
    62     
    63   do while CurrentClipPageNubmer < PageToShowInClip  
    64     ' Display CurrentPage  
    65     ShowPage (WebPage(CurrentPageNubmer))  
    66       
    67     ' add counter  
    68     CurrentClipPageNubmer = CurrentClipPageNubmer + 1  
    69       
    70     ' check our loop         
    71     CurrentPageNubmer = CurrentPageNubmer + 1        
    72     if CurrentPageNubmer = 40 then        
    73       CurrentPageNubmer = 0        
    74     end if      
    75   loop    
    76   ' Reset page clip counter'  
    77   CurrentClipPageNubmer = 0   
    78     
    79   ' close IE      
    80   objExplorer.Quit    
    81     
    82   'wait for next clip  
    83   wscript.sleep WaitTimeAfterClipLoaded            
    84 loop    
    85  
    86 ' ------------------------------------------------------------------------------ '  
    87 ' ------------------------------------------------------------------------------ '  
    88 function ShowPage (URL)  
    89   ' load page        
    90   objExplorer.Navigate URL      
    91        
    92   ' wait while loading         
    93   Do Until (objExplorer.readyState = 4)        
    94     wscript.sleep 100        
    95   Loop          
    96        
    97   ' Show finnaly         
    98   objExplorer.Visible = 1     
    99               
    100   ' wait period'        
    101   wscript.sleep WaitTimeAfterpageLoaded     
    102 end function  
    103  
    104  
    105
    106

    ScottG14 said:

    Aleksey,
    When I run the script I am seeing this error.  Any Ideas Why?  I am running the script on Windows XP from the actually machine not from a remote server.
    Windows Script Host 
     Script:  
     C:\Documents and settings\pwa2.8021X\Desktop\MasterScript.vbs
    Line: 49
    Char: 3
    Error:  The remote server machine does not exist or is unavailable "CreateObject'
    Code 800A01CE
    Source Microsoft VBScript runtime error
    Thanks
    Scott


    Skier



    May be because of corp policy, that evaluate any scripts or etc. If scrip is runing on your local pc, this means it could run or any other if no corporate (domain) policy restrict's its

    Friday, December 19, 2008 8:18 AM