Copia testo da pagina web



  • Copia scadenza da pagina web
    di Max (utente non iscritto) data: 11/09/2009

    Ciao a tutti, mi hanno fatto questo codice in vb ma non funge, il suo compito dovrebbe essere quello di aprire delle pagine web, i link sono scritti nelle celle della colonna "h".
    all'interno di queste pagine web c'è questa riga :

    sun, 01 nov 2009 12:44:20 -0500

    avrei bisogno che nelle celle a fianco dei rispettivi link (colonna "i") mi scrivesse la data che è contenuta nella riga sopra a questa (es. 01/11/2009).
    il codice qui sotto, vedo che apre le pagine web ma non trovo da nessuna parte la scadenza...

    chi mi puo' aiutare ??

    grazie
    max
     
    Option Explicit
    Const READYSTATE_COMPLETE As Long = 4
    
    
    Sub Leggi_XML_da_IE()
    Dim myURL As String
    Dim Testo As String
    Dim RngT As Excel.Range
    Dim Rng As Excel.Range
    Dim myIE As Object
    
    Set myIE = CreateObject("InternetExplorer.Applicati…
    
    Set Rng = [h1:h5]
    
    'volendo non è necessario rendere visibile IE
    'in questo caso commentare la prossima riga
    myIE.Visible = True
    
    On Error Resume Next
    
    For Each RngT In Rng
    myURL = CStr(RngT.Text)
    myIE.navigate myURL
    
    Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
    DoEvents
    Loop
    
    myIE.Refresh
    
    Do While myIE.Busy Or myIE.readyState <> READYSTATE_COMPLETE
    DoEvents
    Loop
    
    Testo = myIE.document.body.innerText
    RngT.Offset(, 1) = EstraiData(Testo)
    Next
    
    myIE.Quit
    
    End Sub
    
    
    Function EstraiData(ByVal sData As String)
    Dim re As Object
    Set re = CreateObject("vbscript.regexp")
    re.ignorecase = True
    
    
    re.Pattern = "[^<]+"
    If re.test(sData) Then
    sData = re.Execute(sData)(0)
    End If
    
    
    re.Pattern = "d{2}s[a-z]{3}sd{4}"
    If re.test(sData) Then
    EstraiData = DateValue(re.Execute(sData)(0))
    End If
    End Function