使用Option Explicit
Public Sub test()
Dim html As HTMLDocument, http As Object, ticker As Range
Set html = New HTMLDocument
Set http = CreateObject("WINHTTP.WinHTTPRequest.5.1")
Dim lastRow As Long, myrng As Range
With ThisWorkbook.Worksheets("Main2")
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set myrng = .Range("A2:A" & lastRow)
For Each ticker In myrng
If Not IsEmpty(ticker) Then
With http
.Open "GET", "https://finance.yahoo.com/quote/" & ticker.Value & "?p=" & ticker.Value, False
.send
html.body.innerHTML = .responseText
End With
On Error Resume Next
ticker.Offset(, 1) = html.querySelector("[data-test=FIFTY_TWO_WK_RANGE-value]").innertext
'ticker.Offset(, 1) = Split(Split(Split(http.ResponseText, "data-test=""FIFTY_TWO_WK_RANGE-value""")(1), "<")(0), ">")(1) ''<<Or this version
On Error GoTo 0
End If
Next
End With
End Sub
并将其安装在计算机上会产生一种怪异的交互作用,即打印网页会将所有字符按1推送。我希望我可以更好地阐明问题,但是您会在代码段中看到它并附带图片。
Roboto:100
@import url('https://fonts.googleapis.com/css?family=Roboto:100');
li {
font-family: sans-serif;
font-wieght: 100;
font-size: 30px;
line-height: 1;
}
span {
font-family: Roboto, sans-serif;
}
ol.lower {
list-style-type: lower-alpha;
}
ol.upper {
list-style-type: upper-alpha;
text-transform: uppercase;
}
.flex {
display: flex;
justify-content: space-around;
}