• VBS统计页面加载时间脚本


    下面是一个通过Excel中的url列表来请求页面,统计页面加载时间,然后记录到Excel中的vbs脚本。由于vbs脚本并不是这方面的最好选择,没有研究过httpWatch软件是如何实现统计页面各个元素加载时间的原理,这个脚本统计出来的时间会有偏差,数据仅供参考。以下是代码:

    1 'Function GetCellNum()
    2 ' On Error Resume Next
    3 ' Set Wshell = CreateObject("Wscript.shell")
    4 ' Set ExcelApp = CreateObject("Excel.Application")
    5 ' ExcelApp.Visible = True
    6 ' Set newBook = ExcelApp.Workbooks.Open("C:/Report.xls")
    7 ' If Err = 0 Then
    8 ' Set excelSheet = ExcelApp.ActiveSheet
    9 ' Set rowCount = excelSheet.Rows.Count
    10 ' For i = 1 To 65535
    11 ' GetCellValue = excelSheet.Cells(i,1)
    12 ' excelSheet.Cells(i,2) = "http://test.gasgoo.cn/TradeSearch/search/SearchNormal.aspx?idty=0.2831222238019109&sType=1&key=" & GetCellValue & ""
    13 ' excelSheet.save
    14   'MsgBox "现在是第"&i&"行"&vbCrLf&"值为:"&GetCellValue
    15 ' Wshshell.Popup GetCellValue,2,"获取的Excel单元格的值为:",0+64
    16 ' If GetCellValue = "" Then
    17 ' rowNum = i - 1
    18 ' GetCellNum = rowNum
    19 ' MsgBox rowNum
    20 ' Exit For
    21 ' Else
    22   'do nothing
    23 ' End If
    24 ' Next
    25 ' Else
    26   'do nothing
    27 ' End If
    28  
    29 ' newBook.SaveAs("C:\KeywordUrl.xls")
    30 ' newBook.Save
    31 ' newBook.Close
    32 ' ExcelApp.Quit
    33
    34 ' Set ExcelApp = Nothing
    35 ' Set Wshell = Nothing
    36 'End Function
    37
    38 'Call GetCellNum()
    39 'i = GetCellNum()
    40 'MsgBox i
    41
    42 Function CountPadLoadTime()
    43 On Error Resume Next
    44 Set Wshell = CreateObject("Wscript.shell")
    45 Set IeObject = CreateObject("InternetExplorer.Application")
    46 Set ExcelApp = CreateObject("Excel.Application")
    47 ExcelApp.Visible= True
    48
    49 Set newBook =ExcelApp.Workbooks.Open("C:/KeywordUrl.xls")
    50
    51 If Err = 0 Then
    52 Set excelSheet = ExcelApp.ActiveSheet
    53
    54 For i = 1 To 65535
    55 GetCellValue = excelSheet.Cells(i,2)
    56 If GetCellValue <> "" Then
    57 'MsgBox GetCellValue
    58 IeObject.Navigate(GetCellValue)
    59 time1 = timer()
    60 'MsgBox time1
    61 a = IeObject.ReadyState
    62 IeObject.visible = True
    63 While IeObject.busy Or ( IeObject.ReadyState<>4 )
    64 wscript.sleep 1
    65 wend
    66 time2 = timer()
    67 'MsgBox time2
    68
    69 costPageLoad = time2 - time1
    70
    71 'Wshshell.Popup costPageLoad,2,"页面加载时间为:",0+64
    72
    73 'MsgBox "页面加载时间为:"& costPageLoad
    74
    75 excelSheet.Cells(i,3) = costPageload
    76 excelSheet.save
    77
    78 WScript.Sleep 1000
    79
    80 time1 = 0
    81 time2 = 0
    82 costPageLoad = 0
    83
    84
    85 Else
    86 Exit For
    87 End If
    88 Next
    89 End If
    90 newBook.SaveAs("c:\Results.xls")
    91 newBook.Close
    92 excelApp.Quit
    93
    94 Call RelaeseResource()
    95 End Function
    96
    97
    98 Function ReleaseResource()
    99 On Error Resume Next
    100 Set excelObject = Nothing
    101 Set ExcelApp = Nothing
    102 Set IeObject = Nothing
    103 End Function
    104
    105 Call CountPadLoadTime()
  • 相关阅读:
    利用高斯金字塔制作图像显著图
    python实现图像高斯金字塔
    使用差分金字塔提取图像边缘 python实现
    使用色彩追踪和形态学运算得到图像中感兴趣区域
    图像掩膜讲解
    图像色彩追踪
    手动绘制方向梯度直方图(HOG)
    Zhang-Suen 图像细化算法python实现
    hilditch图像细化算法python实现
    P2256 一中校运会之百米跑
  • 原文地址:https://www.cnblogs.com/shinhwa/p/1678211.html
Copyright © 2020-2023  润新知