I want to get the session id & csfrtoken from the url: https://www.screener.in/api/company/6596449/quick_ratios/ below is the screenshot of the values.
Also, I tried the below code in vba, but not getting response. please guide, Note the account is a dummy account only to fetch the details.
Sub test()
Dim user As String
Dim pwd As String
Dim path As String
user = "rajesh2.gade@gmail.com"
pwd = "Rain@123"
path = "https://www.screener.in/api/company/6596449/quick_ratios/"
Debug.Print httpGET(path, user, pwd)
End Sub
Public Function httpGET(fn As String, _
Optional authUser As String = vbNullString, _
Optional authPass As String = vbNullString) As String
pHtml = fn
Dim oHttp As Object
Set oHttp = CreateObject("Microsoft.XMLHTTP")
Call oHttp.Open("GET", pHtml, False)
If (authUser <> vbNullString) Then
' need to do basic authentication
' acknowledgement to http://pastie.org/1192157
oHttp.setRequestHeader "Content-Type", "application/json"
oHttp.setRequestHeader "Accept", "application/json"
oHttp.setRequestHeader "Authorization", "Basic " + _
EncodeBase64(authUser + ":" + authPass)
End If
Call oHttp.send("")
Debug.Print oHttp.getAllResponseHeaders
httpGET = oHttp.responseText
Set oHttp = Nothing
End Function
Function EncodeBase64(text As String) As String
Dim arrData() As Byte
arrData = StrConv(text, vbFromUnicode)
Dim objXML As MSXML2.DOMDocument60
Dim objNode As MSXML2.IXMLDOMElement
Set objXML = New MSXML2.DOMDocument60
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64 = Application.Clean(objNode.text)
Set objNode = Nothing
Set objXML = Nothing
End Function
