Results 1 to 2 of 2

Thread: RegExp pattern for retrieving data between 2 Tags

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Location
    http://bbat.forumeiro.com/
    Posts
    86

    Question RegExp pattern for retrieving data between 2 Tags

    Hi
    I need your help about this script.
    What I want to do is just get the data between the <title>Data to be extracted</title> and <!-Mfunc->Data to be extracted<!--/mfunc-->
    So if someone here is kind enough to correct me the syntax pattern to achieve my goal.
    Thank you !
    Code:
    Dim Titre,URL,ie,objFSO,Data,OutPut,objRegex,Match,Matches
        Titre = "Notification de Giveawayoftheday © Hackoo © 2013"
        URL = "http://fr.giveawayoftheday.com/"
        Set ie = CreateObject("InternetExplorer.Application")
        Set Ws = CreateObject("wscript.Shell")
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        ie.Navigate (URL)
        ie.Visible=false
        DO WHILE ie.busy
            wscript.sleep 100
        LOOP
        Data = ie.document.documentElement.innerHTML
        ie.Quit
        Question = MsgBox(RegExp("<title>(.*?)</title>")&vbcr&vbcr&_
        " Le temps restant est :" &vbcr&vbcr&_
        RegExp("<!--mfunc-->(.*?)<!--/mfunc-->")&vbcr&vbcr&_
        "Voulez-vous accéder au site : http://fr.giveawayoftheday.com/  ?",VBYesNO+VbQuestion,Titre)
        If Question = VbYes then
            Ws.Run "http://fr.giveawayoftheday.com/",1,False
        else
            Wscript.Quit
        end if
        Set ie = Nothing
         
    Function RegExp(Motif)    
    Set objRegex = new RegExp
    objRegex.Pattern = Motif 'Motif pour y extraire le code source
    objRegex.Global = False 'une seule instance
    objRegex.IgnoreCase = True 'Ignorer la casse
    Set Matches = objRegex.Execute(Data) 'Execution du la RegExp
    For Each Match in Matches  
        strMatchValue = Match.Value
        RegExp = strMatchValue
    Next
    End Function

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Location
    http://bbat.forumeiro.com/
    Posts
    86

    Thumbs up Re: RegExp pattern for retrieving data between 2 Tags

    I solved the Problem like this :
    Code:
    Option Explicit
    Dim Titre,URL,ie,Ws,Question,Data,objRegex,Match,Matches,i
    	Titre = "Notification de Giveawayoftheday © Hackoo © 2013"
    	URL = "http://fr.giveawayoftheday.com/"
    	Set ie = CreateObject("InternetExplorer.Application")
    	Set Ws = CreateObject("wscript.Shell")
    	ie.Navigate(URL)
    	ie.Visible=false
    	DO WHILE ie.busy
    		wscript.sleep 100
    	LOOP
    	Data = ie.document.documentElement.innerHTML
    	ie.Quit
    	Set ie = Nothing
    	Question = MsgBox(RegExp("<title>(.*)</title>",Data)& vbcr & vbcr &_
        " Le temps restant est : " & RegExp("<!--mfunc-->(.*)<!--/mfunc-->",Data)& vbcr & vbcr &_
        "Voulez-vous accéder au site : ""http://fr.giveawayoftheday.com"" ?",VBYesNO+VbQuestion,Titre)
        If Question = VbYes then
            Ws.Run "http://fr.giveawayoftheday.com/",1,False
        else
            Wscript.Quit
        end if
        
    Function RegExp(Motif,Data)	 
     Set objRegex = new RegExp
     objRegex.Pattern = Motif  
     objRegex.Global = False 'une seule instance  
     objRegex.IgnoreCase = True 'Ignorer la casse  
     Set Matches = objRegex.Execute(Data)  
     If Matches.Count > 0 Then
          Set Match = Matches(0)
       If Match.SubMatches.Count > 0 Then
            For i = 0 To Match.SubMatches.Count-1
    	        RegExp = Match.SubMatches(i)
            Next
        End If
     End If
     Set Matches = Nothing  
     Set objRegex = Nothing  
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width