-
Oct 16th, 2017, 06:18 AM
#1
Thread Starter
Lively Member
Read a source code from web page and extract some data from it
Hi
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
'*****************************************************************
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|