ossiejhmoore

OScript HttpGet Leveraging Apache HttpClient - Example Usage

Aug 18th, 2012
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. Output of example usage code provided below:
  2.  
  3. ==================================================
  4. URL : https://www.google.com
  5. Page Size : 13025
  6. Duration : 281
  7. URL : https://www.yahoo.com
  8. Page Size : 323662
  9. Duration : 1844
  10. URL : https://news.google.com
  11. Page Size : 540853
  12. Duration : 718
  13. JavaObject_InvokeMethod exception: org.apache.http.conn.HttpHostConnectException: Connection to https://abcnews.com refused
  14. JavaObject_InvokeMethod exception: org.apache.http.conn.HttpHostConnectException: Connection to https://cbs.com refused
  15. JavaObject_InvokeMethod exception: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
  16. URL : http://www.google.com
  17. Page Size : 13023
  18. Duration : 156
  19. URL : http://www.yahoo.com
  20. Page Size : 322442
  21. Duration : 1422
  22. URL : http://news.google.com
  23. Page Size : 532204
  24. Duration : 328
  25. URL : http://abcnews.com
  26. Page Size : 101077
  27. Duration : 500
  28. URL : http://cbs.com
  29. Page Size : 81984
  30. Duration : 687
  31. URL : http://nbc.com
  32. Page Size : 50498
  33. Duration : 516
  34. ==================================================
  35. Fastest : http://www.google.com (156)
  36. Slowest : https://www.yahoo.com (1844)
  37. ==================================================
  38.  
  39. Code that produced above output:
  40.  
  41. Assoc retVal
  42. String url
  43. Integer start, duration
  44. Assoc fastest
  45. Assoc slowest
  46. List urls = { \
  47. "https://www.google.com", "https://www.yahoo.com", "https://news.google.com", \
  48. "https://abcnews.com" , "https://cbs.com" , "https://nbc.com",\
  49. "http://www.google.com" , "http://www.yahoo.com" , "http://news.google.com", \
  50. "http://abcnews.com" , "http://cbs.com" , "http://nbc.com"}
  51.  
  52. fastest = Assoc.CreateAssoc()
  53. fastest.Duration = 999999999
  54. fastest.Url = Undefined
  55.  
  56. slowest = Assoc.CreateAssoc()
  57. slowest.Duration = 0
  58. slowest.Url = Undefined
  59.  
  60. echo('')
  61. echo('')
  62. echo('')
  63. echo('')
  64.  
  65. echo(Str.Set(50, "="))
  66. for url in urls
  67. start = Date.Tick()
  68. retVal = $aaamod.Utils.HttpGet(url)
  69. duration = Date.Tick() - start
  70. if (retVal.Ok)
  71.  
  72. echo("URL : ", retVal.Url)
  73. echo("Page Size : ", Length(retVal.Data))
  74. echo("Duration : ", duration)
  75.  
  76. if (fastest.Duration > duration)
  77. fastest.Duration = duration
  78. fastest.Url = url
  79. end
  80.  
  81. if (slowest.Duration < duration)
  82. slowest.Duration = duration
  83. slowest.Url = url
  84. end
  85. end
  86. end
  87. echo(Str.Set(50, "="))
  88.  
  89. echo("Fastest : ", fastest.Url , " (", fastest.Duration , ")")
  90. echo("Slowest : ", slowest.Url , " (", slowest.Duration , ")")
  91. echo(Str.Set(50, "="))
Advertisement
Add Comment
Please, Sign In to add comment