|
楼主 |
发表于 2024-1-2 21:17
|
显示全部楼层
- Sub tableTest()
- Set WinHttp = CreateObject("winhttp.WinHttpRequest.5.1")
- Set HTML = CreateObject("htmlfile")
- Set oWindow = HTML.ParentWindow
- Url = "https://www.chinamoney.com.cn/chinese/bkcurvclosedyhis/?bondType=CYCC000&reference=1"
- With WinHttp
- .Open "GET", Url, False
- .send
- strText = .responsetext
- '' Debug.Print strText
- End With
- HTML.body.innerhtml = strText
- Set tables = HTML.getElementsByClassName("tableFull")
- Set Table = tables(0)
-
- oWindow.ClipboardData.SetData "text", Table.outerHTML
-
- ActiveSheet.Range("a1").Select
- ActiveSheet.Paste
-
- Set WinHttp = Nothing
- Set HTML = Nothing
- Set oWindow = Nothing
- End Sub
- ''''ËùÓбí¸ñ
- Sub alltableTest()
- Set WinHttp = CreateObject("winhttp.WinHttpRequest.5.1")
- Set HTML = CreateObject("htmlfile")
- Set oWindow = HTML.ParentWindow
- Url = "https://www.chinamoney.com.cn/chinese/bkcurvclosedyhis/?bondType=CYCC000&reference=1"
- With WinHttp
- .Open "GET", Url, False
- .send
- strText = .responsetext
- '' Debug.Print strText
- End With
- HTML.body.innerhtml = strText
- Set tables = HTML.getElementsByTagName("table")
- aa = 1
- For i = 0 To tables.Length - 1
- Set Table = tables(i)
-
- '''дÈë¼ôÇÐ°å µÚÒ»ÖÖ
- oWindow.ClipboardData.SetData "text", Table.outerHTML
-
- '''дÈë¼ôÇÐ°å µÚ¶þÖÖ
- ' Set clipboard = New MSForms.DataObject
- ' clipboard.SetText Table.outerHTML
- ' clipboard.PutInClipboard
-
- ActiveSheet.Cells(1, aa).Select
- ActiveSheet.Paste
- oWindow.ClipboardData.SetData "text", ""
- aa = ActiveSheet.UsedRange.Columns.Count + 2
- Next
- Set WinHttp = Nothing
- Set HTML = Nothing
- Set oWindow = Nothing
- End Sub
复制代码 |
|