vba抓取網(wǎng)頁數(shù)據(jù)到excel 如何用vba抓取網(wǎng)頁數(shù)據(jù)?
如何用vba抓取網(wǎng)頁數(shù)據(jù)?Subcc()單元格.清除內(nèi)容SetoDoc=CreateObject(“htmlfile”)與CreateObject()WinHttp.WinHttpRequest.5.
如何用vba抓取網(wǎng)頁數(shù)據(jù)?
Subcc()單元格.清除內(nèi)容SetoDoc=CreateObject(“htmlfile”)與CreateObject()WinHttp.WinHttpRequest.5.1 “)。打開“GET”,“”,F(xiàn)alse.Send.WaitForResponseoDoc.body.innerHTML=.responsetext設(shè)置=oDoc.All.標(biāo)簽(“table”)(7)。i=0的行Tor.長度-1 k=[a65536]。結(jié)束(3)。J=0或(i)的行。單元格。長度-1個(gè)單元格(K1,J1)=R(I)。細(xì)胞(J)。InnerText nextj nexti setr=nothing endwith endsub
excel界面操作:數(shù)據(jù)--導(dǎo)入外部數(shù)據(jù)--創(chuàng)建新的Web查詢:在界面的地址欄中輸入網(wǎng)址,然后選擇要更新的數(shù)據(jù)區(qū)域--導(dǎo)入--選擇要將數(shù)據(jù)放入的單元格(修改屬性,如刷新頻率等)如有必要--確認(rèn)。這樣,當(dāng)網(wǎng)頁數(shù)據(jù)發(fā)生變化時(shí),Excel數(shù)據(jù)也會(huì)發(fā)生變化。如果必須使用VBA,請使用錄制宏對(duì)其進(jìn)行修改。