3楼的回答非常的牛,但是不利于新手学习。
我也制作了一份,但愿能够帮助到你!
一条龙服务,代码+视频讲解:
1、代码如下:
Sub byWanao()
Dim oHtml As Object, getText$, tmpStr, i%, j%, putData
Set oHtml = VBA.CreateObject("WinHttp.WinHttpRequest.5.1")
Dim sUrl As String
sUrl = "https://q.stock.sohu.com/hisHq?code=cn_" & [B1]
With oHtml
.Open "GET", sUrl, False
.send
getText = .ResponseText
End With
tmpStr = Split(Replace(Split(Split(getText, "[[")(1), "]]")(0), """", ""), "],[")
For i = 0 To UBound(tmpStr)
putData = Split(tmpStr(i), ",")
For j = 0 To UBound(putData)
Cells(i + 2, j + 1) = putData(j)
Next
Next
Set oHtml = Nothing
End Sub
2、视频讲解地址:
https://www.zhihu.com/zvideo/1473182833364070400
|