|
用好啦,记得赏花啊!
- Sub Main2()
- Dim strText As String
- ' For i = 1 To 36
- strText = HtmlStr("http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page=1&num=80&sort=symbol&asc=1&node=shfxjs&symbol=&_s_r_a=setlen") & "},"
- ' Next
- 'strText = strConv1(strText)
- Set reg = CreateObject("vbscript.regexp") 'ÕýÔò:"
- reg.Global = True
- reg.Pattern = "[a-z"":]"
- strText = reg.Replace(strText, "")
-
- strText = Replace(strText, ",,", ",")
- strText = Replace(strText, ",1,", "")
- 'Debug.Print strText
- Cells.ClearContents
- Dim arr() As String
- arr = Split(strText, "},")
- Range("b2:b" & (UBound(arr) + 2)) = Application.Transpose(arr)
-
- Columns("B:B").TextToColumns Destination:=Range("B1"), Comma:=True, FieldInfo:=Array(Array(1, 1), Array(2, 9))
- [a2] = 1: [a3] = 2: [a2:a3].AutoFill Range("a2:a" & UBound(arr) + 1)
- ' Rows(1).Insert
- Range([a1], Cells(1, "t")) = Split("ÐòºÅ ´úÂë Ãû³Æ ×îÐÂ¼Û Õǵø¶î Õǵø·ù ÂòÈë Âô³ö ×òÊÕ ½ñ¿ª ×î¸ß ×îµÍ ³É½»Á¿/ÊÖ ³É½»¶î/Íò Êо» ×ÜÊÐÖµ Á÷ͨÊÐÖµ »»ÊÖ")
- End Sub
- Function HtmlStr(url As String) As String
- Dim xmlHttp
- Set xmlHttp = CreateObject("Microsoft.XMLHTTP")
- xmlHttp.Open "GET", url, False
- xmlHttp.send
- If xmlHttp.ReadyState = 4 Then
- url = StrConv(xmlHttp.responseBody, vbUnicode)
- Else
- HtmlStr = ""
- Exit Function
- End If
- Set xmlHttp = Nothing
-
- Dim i1 As Long, i2 As Long
- i1 = InStr(1, url, "[")
- i2 = InStr(i1, url, "]")
- url = Mid(url, i1 + 1, i2 - i1 - 2)
- url = Replace(url, """:", ",")
- url = Replace(url, """", "")
- url = Replace(url, "{", "")
- HtmlStr = url
- End Function
复制代码
|
评分
-
1
查看全部评分
-
|