上網爬了一下,目前只會寫到以下登入網頁
但後續要下載檔案的程式碼就不會了,可以請大師們幫幫忙嗎~~~~另外想請問大師們如果這不用VBA來寫,是不是用.vbs或.bat也可以做到,或哪一個會比較有效率呢?謝謝∼∼∼∼
------------------------------------------------------------------------
Option Explicit
Sub test()
Dim i As Integer, vDoc As Object
With CreateObject("InternetExplorer.Application")
'With IE
.Visible = True
.Navigate "http://10.62.21.121/phpbb/viewtopic.php?f=4&t=106"
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
Set vDoc = .Document.getElementsByTagName("INPUT")
For i = 0 To vDoc.Length - 1
If vDoc(i).Name = "username" Then vDoc(i).Value = "XXXXX"
If vDoc(i).Name = "password" Then vDoc(i).Value = "XXXXX"
If vDoc(i).Value = "登入" Then vDoc(i).Click
Next
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
End With
End Sub
------------------------------------------------------------------------
以上可以登入網頁,登入後的網址會變成http://10.62.21.121/phpbb/viewtopic.php?f=4&t=106&sid=4d34c6c0c2f8e4953ab93c3a46cdd118
欲每日下載以下2個檔案至D:\test,檔名依原下載檔名不變提醒:每天檔案日期會更新,2個檔案的原始碼./download/file.php?id=XXXX,XXXX每天的數字也都不一樣,但都一樣下載至D:\test資料夾並維持原檔名即可