0

I'm working on a VBA code where I want to get cookie after every 30 seconds. My formula is as below but I don't have much knowledge of VBA. Kind help will be really appreciated

Function GetCookie(strUrl)
With CreateObject("WinHttp.WinHttpRequest.5.1")
    .Open "GET", strUrl, False
    .SetRequestHeader "REFERER", strUrl
    .SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
    .SetRequestHeader "Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
    .SetRequestHeader "Accept-Language", "en-us,en;q=0.5"
    .SetRequestHeader "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
    .Send
    strCookie = .getAllResponseHeaders
    strCookie = Split(strCookie, vbCrLf)
    GetCookie = Trim(Split(Split(strCookie(5), ";")(0), ":")(1)) & "; " & Trim(Split(Split(strCookie(6), ";")(0), ":")(1))
End With
End Function




Sub get_cookies()
MsgBox (GetCookie("https://www.nseindia.com/market-data/equity-derivatives-watch"))
Range("$A$1").Value = GetCookie("https://www.nseindia.com/market-data/equity-derivatives-watch")
End Sub
  • Does this answer your question? [VBA Macro On Timer style to run code every set number of seconds, i.e. 120 seconds](https://stackoverflow.com/questions/2319683/vba-macro-on-timer-style-to-run-code-every-set-number-of-seconds-i-e-120-secon) – braX Oct 23 '21 at 08:57

0 Answers0