|
跟着姐儿的教程看了好几天了,这个真真是我们初学者的领航人!
以前是拿来主义,现在有兴趣来慢慢学了!
我在学习过程中,试着抓历史天气,https://lishi.tianqi.com/changshou/202406.html,他只给看10天,点更多后,显示整个月,但是换网址了,前面10天的可以提取出来,后面的怎么也没有搞明白怎么弄!!
哪位老师指导下!!- Sub 练习()
- Dim strText As String, arr
- ' m = "changshou"
- ' n = "202406"
- With CreateObject("MSXML2.XMLHTTP") 'CreateObject("WinHttp.WinHttpRequest.5.1")
- .Open "GET", "https://lishi.tianqi.com/changshou/202406.html ", False
- .setRequestHeader "Content-Type", ""
- .setRequestHeader "Referer", ""
- .Send
- strText = .responsetext
- Debug.Print strText
- End With
- arr = Split(strText, "<li >")
- ReDim crr(1 To 31, 1 To 5)
- For i = 1 To UBound(arr)
- brr = Split(arr(i), "</div>")
- crr(i, 1) = Split(Split(brr(0), ">")(1), " 星期")(0)
- crr(i, 2) = Split(Split(brr(1), ">")(1), "℃")(0)
- crr(i, 3) = Split(Split(brr(2), ">")(1), "℃")(0)
- crr(i, 4) = Split(brr(3), ">")(1)
- crr(i, 5) = Split(brr(4), ">")(1)
- Next i
- '历史天气他只给看10天,点更多后,显示整个月,但是换网址了,前面可以提取出来,后面的怎么也没有搞明白怎么弄!!
- With CreateObject("MSXML2.XMLHTTP") 'CreateObject("WinHttp.WinHttpRequest.5.1")
- .Open "POST", "https://lishi.tianqi.com/monthdata/changshou/202406", False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
- .setRequestHeader "Accept", "application/json, text/javascript, */*; q=0.01"
- .setRequestHeader "Referer", "https://lishi.tianqi.com/changshou/202406.html "
- .Send
- strText = .responsetext
- Debug.Print strText
- End With
- End Sub
复制代码 |
|