looking for some solutions? You are welcome.

SOLVED: Why Calling a Number With Cell Name Comes Empty?

Hugues Lin:

if i call

=GetElementByRegex(A3,"placeholder=""(.*?)"">")

its working

but when i want to take number or another code

A2=https://www.alexa.com/siteinfo/taiwantrade.com/

=GetElementByRegex(A2,"<!-- Alexa web traffic metrics are available via our API at http://aws.amazon.com/awis -->(.*?)</strong>")

its comes Empty.. i dont know why..i am new one

The code i am using... Thanks

Public Function GetElementByRegex(url As String, reg As String)
Dim XMLHTTP As Object, html As Object, objResult As Object
Set XMLHTTP = CreateObject("MSXML2.serverXMLHTTP")
XMLHTTP.Open "GET", url, False
XMLHTTP.setRequestHeader "Content-Type", "text/xml"
XMLHTTP.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0"
XMLHTTP.send
Set html = CreateObject("htmlfile")
html.body.innerHTML = XMLHTTP.ResponseText
Set regEx = CreateObject("VBScript.RegExp")
regEx.Pattern = reg
regEx.Global = True
If regEx.Test(XMLHTTP.ResponseText) Then
    Set matches = regEx.Execute(XMLHTTP.ResponseText)
    If IsMissing(index) Then
        GetElementByRegex = matches(0).SubMatches(0)
    Else
        GetElementByRegex = matches(index).SubMatches(0)
    End If
    Exit Function
End If
GetElementByRegex = ""

End Function



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent