如何不用股票软件查看当前股市行情

2025-10-26 12:16:11

1、打开附件的记事本:

如何不用股票软件查看当前股市行情

2、将以下代码复制粘贴到文件中(注意:股票代码sh600050,sh600018,sh600008可以自行更改为其他股票代码):

stocknames = "sh600050,sh600018,sh600008"

result = GetData(stocknames)

t = "股票名称 昨收盘 涨跌价(涨跌幅)" & vbTab & "最新价" & vbNewLine & " ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄" & vbNewLine

For i = 0 To UBound(result) - 1

    tmp = Split(result(i), ",")

    x = 3

    If tmp(x) = 0 Then x = 2

    If tmp(x) >= tmp(2) Then jj = "+" Else jj = "-"

    g = tmp(0) & Chr(32) & FormatNumber(tmp(2)) & Chr(32) & jj & FormatNumber(Abs(tmp(x) - tmp(2)), , -1) & "(" & jj & FormatPercent(Abs(tmp(x) / tmp(2) - 1), , -1) & ")" & " " & vbTab & FormatNumber(tmp(x))

    If i < UBound(result) Then t = t & g & vbNewLine

Next

CreateObject("wscript.shell").popup t, 5, "", 4096

Function GetData(StockCode)

    Url = "http://hq.sinajs.cn/stock.php?rn=@RANDOM@&list=" & StockCode

    Url = GetHttp(Url)

    tmp = Split(Url, ";")

    For i = 0 To UBound(tmp)

        tmp(i) = Mid(tmp(i), InStr(1, tmp(i), """", vbTextCompare) + 1)

        If Len(tmp(i)) > 3 Then tmp(i) = Left(tmp(i), Len(tmp(i)) - 3)

    Next

    GetData = tmp

End Function

Function GetHttp(Url)

    On Error Resume Next

    Set objXML = CreateObject("Microsoft.XMLHTTP")

    With objXML

        .Open "Get", Url, False, "", ""

        .sEnd

        GetHttp = .ResponseBody

    End With

    GetHttp = BytesToBstr(GetHttp, "GB2312")

    Set objXML = Nothing

    On Error GoTo 0

End Function

Function BytesToBstr(strBody, CodeBase)

    Set objStream = CreateObject("Adodb.Stream")

    With objStream

        .Type = 1

        .Mode = 3

        .Open

        .Write strBody

        .Position = 0

        .Type = 2

        .Charset = CodeBase

        BytesToBstr = .ReadText

    End With

    objStream.Close

    Set objStream = Nothing

End Function

如何不用股票软件查看当前股市行情

3、保存此文件,并命名为hq.vbs:

如何不用股票软件查看当前股市行情

4、找到刚才保存的hq.vbs文件:

如何不用股票软件查看当前股市行情

5、双击运行,即可看到股票行情:

如何不用股票软件查看当前股市行情

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢