【问题标题】:how to get cookies in vba and store in excel如何在vba中获取cookie并存储在excel中
【发布时间】:2022-07-10 12:05:59
【问题描述】:
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()
(GetCookie("https://www.nseindia.com/market-data/equity-derivatives-watch"))
End Sub

好的,上面的代码对我有用 我是 excel 新手 我想知道如何将这些 cookie 存储在 excel 单元格或 excel 表格中,请帮助

【问题讨论】:

  • Range("A1").Value = GetCookie(urlHere)

标签: excel vba


【解决方案1】:

如何获取这个 url 的 cookie https://www.nseindia.com/api/equity-meta-info?symbol=BANKNIFTY 当我尝试导入时,它与门户完全不同,这使我手动刷新数据,而不是自动刷新。我希望有人能帮我解决这个问题。

【讨论】:

    猜你喜欢
    • 2010-11-13
    • 2022-01-02
    • 1970-01-01
    • 2021-03-30
    • 1970-01-01
    • 2021-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多