'Why the output of web scraping is null while URL is correct

All the string and integers are perfect in my programing but the output is not showing correct value its giving "0". Please help me there in my project.

Public Sub BN_O_CE_Test()
Dim ws As Worksheet, re As Object, p1, p2 As String, s1, s2, r1, r2 As Integer
Dim URL, URR As String

p1 = """totalBuyQuantity"":""(.*?)"""
p2 = """totalSellQuantity"":""(.*?)"""
Set re = CreateObject("VBScript.RegExp")

URL = "https://www1.nseindia.com/live_market/dynaContent/live_watch/get_quote/GetQuoteFO.jsp?underlying=BANKNIFTY&instrument=OPTIDX&expiry=07APR2022&strike=37400.00&type=CE#"
With CreateObject("MSXML2.XMLHTTP")
        .Open "GET", URL, False
        .setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
        .send
        If .Status = 200 Then
            r1 = GetValue(re, .responseText, p1)
        Else
            r1 = "Failed connection"
        End If
        If .Status = 200 Then
            r2 = GetValue(re, .responseText, p2)
        Else
            r2 = "Failed connection"
        End If
End With

Debug.Print r3
Debug.Print r3
Debug.Print URL
End Sub

Public Function GetValue(ByVal re As Object, ByVal inputString As String, ByVal pattern As String) As String
With re
    .Global = True
    .pattern = pattern
    If .test(inputString) Then  ' returns True if the regex pattern can be matched agaist the provided string
        GetValue = .Execute(inputString)(0).submatches(0)
    Else
        GetValue = "0"
    End If
End With

End Function

I am using it some other URL's example "https://www1.nseindia.com/live_market/dynaContent/live_watch/get_quote/GetQuoteFO.jsp?underlying=BANKNIFTY&instrument=FUTIDX&expiry=28APR2022&strike=-&type=-" but in this url the vbscrip.regx is not bringing exact value from the web as it seen. it showing "0".



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source