Quote real time prices from aastock

henryvii99

New Member
Joined
Apr 22, 2011
Messages
32
Hello everyone,

I had a UDF which can quote the real time prices from aastock, which basically found the span class "pos bold","neg bold" or "unc bold" in the html (May thanks to pbornemeier!)

The site is:
http://www.aastocks.com/en/ltp/rtquote.aspx?symbol=00008

The code is:

Code:
 Dim aryTypes As Variant
    
    aryTypes = Array("pos bold", "neg bold", "unc bold")
 
    On Error GoTo er
    Set xlhttp = CreateObject("Msxml2.XMLHTTP")
    With xlhttp
        .Open "get", "http://www.aastocks.com/sc/ltp/rtquote.aspx?symbol=" & dm & "&time=" & Timer, False
        .send
 
        sOutput = StrConv(.responsebody, vbUnicode)
        For lx = LBound(aryTypes) To UBound(aryTypes)
            lPosition = InStr(sOutput, aryTypes(lx))
            If lPosition > 0 Then 'search value was found
                sExtract = Mid(sOutput, lPosition, 100) 'get enough of a string to include the % if it exists
                'Debug.Print aryTypes(lx), Trim(sExtract)
                If InStr(sExtract, "%") > 0 Then
                    'Don't want
                Else
                    sType = aryTypes(lx)
                    Exit For
                End If
            End If
        Next
        
        sExtract = Mid(sExtract, InStr(sExtract, ">") + 1, 100)
        StockVal = Left(sExtract, InStr(sExtract, "<") - 1)
        'Debug.Print dm, sType, StockVal
        
    End With
    Set xlhttp = Nothing
    Exit Function
er:
    StockVal = "err"
End Function

Now I want to quote the volume by Excel UDF, which is the first div class named "floatR p2" in the elements. This class will not give any weird outputs (sometimes the price gives a percentage and therefore need a lot of codes to troubleshoot) as in above, so I tried to modify the codes, but it doesn't work.

Many thanks in advance!!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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