Do While .Busy Or .readyState <> 4: DoEvents: Loop
End With
End Sub
Private Sub 圖形更新()
If IE Is Nothing Then Get_Ie
If Msg Then MsgBox "驗證圖 更新完畢"
Msg = False
With IE
.Refresh
Do While .Busy Or .readyState <> 4: DoEvents: Loop
網路圖片存檔 .Document.ALL.tags("IMG")(0).href
End With
Sheet1.Shapes("驗證圖").Fill.UserPicture 圖形 '
End Sub
Private Sub 網路圖片存檔(img As String)
Dim xml As Object '用來取得網頁資料
Dim stream 'As ADODB.stream '用來儲存二進位檔案
Set xml = CreateObject("Microsoft.XMLHTTP")
Set stream = CreateObject("ADODB.stream")
xml.Open "GET", img, 0
xml.send
With stream
.Open
.Type = 1
.write xml.ResponseBody
If Dir(圖形) <> "" Then Kill 圖形
.SaveToFile (圖形)
.Close
End With
End Sub
複製代碼
作者: flask 時間: 2014-12-10 19:29
感謝GBKEE大大的回答!
Private Sub 網路圖片存檔(img As String)
Dim xml As Object '用來取得網頁資料
Dim stream 'As ADODB.stream '用來儲存二進位檔案
Set xml = CreateObject("Microsoft.XMLHTTP")
Set stream = CreateObject("ADODB.stream")
xml.Open "GET", img, 0
xml.send
With stream
.Open
.Type = 1
.write xml.ResponseBody
If Dir(圖形) <> "" Then Kill 圖形
.SaveToFile (圖形)
.Close
End With
End Sub
以這方式下載的圖片與IE頁面的圖不是相同的圖
要如何下載回來的是IE頁面的圖,因為它是PNG檔
我試了幾種方式都沒辦法是IE頁面的圖,驗證碼的
圖要轉成BMP格式才能做2值化的處理.如果不是PNG
檔的話用GetClipboardData就可以處理了!一直想
破頭個人的功力實在太淺了還在學習中!希望老師
能提點一下!作者: flask 時間: 2014-12-11 02:39
Sub test()
Dim e As Object, a As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
'券商買賣證券日報表查詢系統(一般交易)
.Navigate "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/brokerBS.php?l=zh-tw"
Do While .Busy Or .readyState <> 4: DoEvents: Loop
.Document.ALL.tags("INPUT")("rdo_search_stk").Value = 1
.Document.ALL.tags("INPUT")("input_search_site").Value = Trim(1258)
Set a = .Document.ALL.tags("BUTTON")
For Each e In a
If e.ID = "header_search_btn" Then
e.Click
Exit For
End If
Next
End With
End Sub作者: wufonna 時間: 2014-12-14 18:08
Sheets("上櫃股票").Activate
With CreateObject("InternetExplorer.application") '創建一個空的ie
.Visible = True '讓ie可見
.Navigate "http://www.gretai.org.tw/web/stock/aftertrading/broker_trading/brokerBS.php?l=zh-tw"
Do Until .ReadyState = 4 '等待ie完畢載入
DoEvents
Loop
code = InputBox("輸入驗證碼", "code", code)
For Each stock In Range([a2], [a65536].End(xlUp))'股票代號