Home > Software engineering >  Questions about the pictures in the iFrame in vb obtain webbrowser
Questions about the pictures in the iFrame in vb obtain webbrowser

Time:09-25

IFrame snippet below

I am using vb6 + webbrowser
SRC="https://bbs.csdn.net/ddxt/RandomCode? Id=1 "are random captcha images, BMP picture


The expert help have a look at how the images interception, assigned to Picture or save will do

CodePudding user response:

Stick a previously seen and collection of code, here are the methods of 2, you see:
 'such as use webbrowser open the address http://www.xici.net/user/reg.asp 
"' purpose want to on the picture shows the current web page captcha image

' 'now everyone seems all is to use the following method to get the
The Set CtrlRange=WebBrowser1. Document. Body. CreateControlRange ()
CtrlRange. Add WebBrowser1. Getelementbyid (" showverifyimg ")
CtrlRange. ExecCommand (" Copy ")
Picture1. Picture=Clipboard. GetData
"' but I don't feel very convenient

"', using the method of reading pictures cache address some website can't read, don't know why
'there are no other method????? O code




Private Sub CommandButton1_Click ()
Dim arr () As Byte
On the Error Resume Next
The Set ms=CreateObject (" msscriptcontrol. Scriptcontrol)
Ms. Language="JavaScript"

With CreateObject (" WinHttp WinHttpRequest. 5.1 ")
. Open the "GET", "http://www.xici.net/user/reg.asp", False
. SetRequestHeader "Connection", "Keep Alive -
". Send

. Open the "POST", "http://www.xici.net/setcode.asp", False
. SetRequestHeader "Referer", "http://www.xici.net/user/reg.asp"
. SetRequestHeader "x - requested - with", "the XMLHttpRequest
". SetRequestHeader "Accept", "application/json, text/javascript, */*; Q=0.01 "
The content-type. SetRequestHeader ", "" application/x - WWW - form - urlencoded; Charset=utf-8 "
. SetRequestHeader "Connection", "Keep Alive -
". Send "act=setkeyvalue"
Tt1=Split (responsetext, "" "") (3)

. Open the "GET", "http://www.xici.net/xiciservice/verifyimg2.asp? Key="& amp; Tt1, False
. SetRequestHeader "Referer", "http://www.xici.net/user/reg.asp"
. SetRequestHeader "Connection", "Keep Alive -
". Send 'get verification code
Arr=. ResponseBody

Open "D: \ tp1. GIF" For Binary As # 1
Put # 1, arr
Close # 1

Do Until Dir (" D: \ tp1. GIF ") & lt;> "
"DoEvents
Loop

ActiveSheet. Cells (2, 2). Select
The Set s=ActiveSheet. Pictures. Insert (" D: \ tp1. GIF ")
S.S hapeRange. ScaleWidth 2, msoFalse msoScaleFromTopLeft
S.S hapeRange. ScaleHeight 2, msoFalse msoScaleFromTopLeft

Sryzm=InputBox (" please enter the verification code ")
Spyware doctor elete
The Set WshShell=CreateObject (" WScript. Shell ")
WshShell. Run Environ $(" comspec ") & amp; "/Del/F/Q" c "" & amp; "D: \ tp1. GIF" "", vbHide, False
The Set WshShell=Nothing

End With
End Sub

'

.

CodePudding user response:

The first approach some sites there is a problem, but also a little small problems
refresh. The second is directly with the WinHttp WinHttpRequest. 5.1 to access?
I want to use Webbrowser is to do, because that looks more intuitive, strong commonality,. The WinHttp WinHttpRequest. 5.1 code too complicated

CodePudding user response:

Learn from the 1st floor!

CodePudding user response:

Topc008
What is the tt1
  • Related