|
请参考!登录方式还不对,有时候能取到数据。详细代码请参考附件。
Sub hnky() 'https://pqfans.com/2230.html‘http://club.excelhome.net/thread-1418196-1-1.html
Dim s As String, URL, Udate, Fromto, Eendto, arr(1 To 500, 1 To 16)
r = Cells(Rows.Count, 1).End(xlUp).Row + 3
Range("a3:o" & r) = ""
Application.ScreenUpdating = 0 '关闭屏幕显示
URL = "https://www.caipiaokong.com/chart/hnky.html" ''1分钟
With CreateObject("MSXML2.XMLHTTP") ' With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", URL, False
.SetRequestHeader "Accept-Language", "zh-CN,zh;q=0.8"
.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.SetRequestHeader "Connection", "Keep-Alive"
.SetRequestHeader "If-Modified-Since", "0"
.SetRequestHeader "Referer", "https://www.caipiaokong.com/chart/hnky.html?QueryCount=50"
.send '"loginType=subscriber&username=13686254412&password=441785"
'Application.Wait Now + TimeValue("0:00:03") '延时
s = .responsetext
End With
's = [a1]
'Debug.Print s
If InStr(s, "从 第") = 0 Then Exit Sub
V = Split(s, "xs0'>")
RW = UBound(V)
QH = Left(Split(s, "从 第")(1), 12)
For i = 1 To RW
If i > 1 Then QH = QH + 1
HZ = Replace(Split(Split(V(i), "xi1'>")(1), "</")(0), ",", "")
arr(i, 1) = "第" & QH & "期"
arr(i, 2) = Split(Split(V(i), "xi1'>")(1), "</")(0)
arr(i, 3) = MySUM(HZ, 1)
arr(i, 4) = MySUM(HZ, 3)
arr(i, 5) = Right(arr(i, 3), 1)
arr(i, 6) = Right(arr(i, 4), 1)
arr(i, 8) = MyMax(HZ)
arr(i, 9) = MyMin(HZ)
arr(i, 7) = arr(i, 8) - arr(i, 9)
arr(i, 10) = Round(arr(i, 3) / 5, 0)
arr(i, 11) = JOSF(HZ, 1)
arr(i, 12) = 5 - arr(i, 11)
arr(i, 13) = LSSF(HZ, 0) * 1
arr(i, 14) = LSSF(HZ, 1) * 1
arr(i, 15) = LSSF(HZ, 2) * 1
Next
Range("a3:P" & RW + 4) = arr
Application.ScreenUpdating = 1 '打开屏幕显示
End Sub
|
|