Extract text from span element xml

S_Wish

Board Regular
Joined
Jan 4, 2017
Messages
216
Hi board!
I want to get a text under span class = "black" from that website (its date and time of auction end):
https://auction.violity.com/63039365-kollekciya-shkatulok-13sht
Haven`t found any example except getting table content, but can`t handle even html-file opening :(
Rich (BB code):
Sub Web_Test()
Dim xml    As Object
Dim html   As Object
Dim objTable As Object
Dim result As String
Dim lRow As Long
Dim lngTable As Long
Dim lngRow As Long
Dim lngCol As Long
Dim ActRw As Long
Set xml = CreateObject("MSXML2.XMLHTTP.6.0")
With xml
.Open "GET", "https://auction.violity.com/63039365-kollekciya-shkatulok-13sht", False
'.Open "GET", "http://www.ernaehrung.de/lebensmittel/de/F110000/Apfel.php", False
.send
End With
result = xml.responseText  'I have error here like: "selected encoding is not supported"
Set html = CreateObject("htmlfile")
html.body.innerHTML = result
....

end sub
thanks in advance!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try this;

Code:
Sub Test()
    Dim URL As String
    Dim IE As Object
    
    URL = "https://auction.violity.com/63039365-kollekciya-shkatulok-13sht"
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Navigate URL
    
    Do Until IE.ReadyState = 4
    Loop
    
    RetVal = IE.Document.getElementsByClassName("black")(3).InnerText
    
    MsgBox RetVal
    
    IE.Quit
    Set IE = Nothing
End Sub
 
Upvote 0
Haluk, thanks for your reply, that worked!
It uses internet explorer, so it is slow, do you know how take data without opening IE, using CreateObject("MSXML2.XMLHTTP.6.0") ? I just want to know how to open my link with that.
 
Upvote 0
Hi again;

Because of the encoding of the URL, i was not able to extract the data you want by HTTP request, at first.

Now, this has been fixed by the below code.

Code:
Sub Test()
        Dim W As Object
        Dim URL As String, str1 As String, str2 As String, RetVal As String
        Dim x1 As Integer, x2 As Integer
        
        URL = "https://auction.violity.com/63039365-kollekciya-shkatulok-13sht"
        
        On Error Resume Next
            Set W = CreateObject("winhttp.winhttprequest.5")
            If Err.Number <> 0 Then
                Set W = CreateObject("winhttp.winhttprequest.5.1")
            End If
        On Error GoTo 0
        
        On Error Resume Next
        W.Open "GET", URL, False
        W.send
        
        W.WaitForResponse
        
        If Err Then
            MsgBox "Server is not responding...", vbCritical
            Exit Sub
        End If
       
        If W.Status = 200 Then
            RetVal = StrConv(W.responseBody, vbUnicode)
            str1 = "
"
            str2 = "[B]+5"
            
            x1 = InStr(1, RetVal, str1)
            x2 = InStr(1, RetVal, str2)
            
            RetVal = Mid(RetVal, x1 + Len(str1), x2 - x1 - Len(str1))
            
            MsgBox RetVal
        End If
        
    Set W = Nothing
End Sub
[/B]
 
Last edited:
Upvote 0
hi again, Haluk!
thanks for help, I also found out that only problem was httpSecured; thanks for helping to access site data! now i can just parse it as i want!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top