Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

Read a source code from web page and extract some data from it

$
0
0
Hi :wave:
I want to read a source code from web page and extract some data from it. I used here in my example a RegEx for extracting the data, but i didn't get any data, perhaps this is due from unicode or the pattern dosn't match ? When i test this pattern with RegExBuddy it match, but in vbscript no ? Perhaps, i miss something in the code, or i must re-write by another way ?

Here is my try :
Code:

sSrcUrl = "https://fr.giveawayoftheday.com/"
Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
bGetAsAsync = False
oHTTP.open "GET", sSrcUrl, bGetAsAsync
oHTTP.send
If oHTTP.status <> 200 Then
WScript.Echo "unexpected status = " & oHTTP.status & vbCrLf & oHTTP.statusText
WScript.Quit
End If
Data = oHTTP.responseText
wscript.echo Extract(Data)
'****************************************************************
Function Extract(Data)
        Dim oRE,oMatches,Match,Line
        set oRE = New RegExp
        oRE.IgnoreCase = True
        oRE.Global = True
        oRE.MultiLine = True
        oRE.Pattern = "<div class=""giveaway_wrap cf"">(\r.*\n.*){17}</div>"
        set oMatches = oRE.Execute(Data)
        If not isEmpty(oMatches) then
                For Each Match in oMatches 
                        Line = Match.Value
                        Extract = Line
                Next
        End if
End Function
'*****************************************************************


Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>