Home > Software engineering >  VB6 why download page source code blank?
VB6 why download page source code blank?

Time:09-16

the following code, figures add to more than 70 or 100, access to the source of why a blank? Is the following red S=oDoc. Body. The innerText value is empty, Text3 also became a blank, what reason is this? Seek a solution?
I want to kept down, get belong to


Private Sub Form_Load ()
Text1="19191111111"
End Sub

Private Sub Text3_Change ()
"C: \ 2. TXT" Open For Append As # 3
Print # 3, Text1 + Text2
Close # 3
End Sub

Private Sub Command1_Click ()
Timer1=Enabled
Timer1. Interval=100
End Sub

Private Sub Command2_Click ()
Timer1=False
End Sub

Private Sub Command3_Click ()
Text1=Text1 + 1
End Sub

Private Sub Command4_Click ()
On the Error Resume Next
Dim S As String
The Set oDoc=CreateObject (" htmlfile ")
The Set ms=CreateObject (" MSScriptControl. ScriptControl)
Ms. Language="JScript"
With CreateObject (" Microsoft. XMLHTTP ")
. Open the "GET", "https://www.baidu.com/s? Wd="& amp; Text1, False
. SetRequestHeader "the if-modified-since", "Thu, 01 Jan 1970 00:00:00 GMT" 'take all the latest data is equal to "0" can also achieve the latest
. Send
ODoc. Body. InnerHTML=. The responseText
S=oDoc. Body. The innerText
End With
Open "c: \ 1. TXT" For the Output As # 30
Print # 30, S
Close # 30

'Dim s As String
Text3=S
Dim As Long l
L=InStr (S, "query") - InStr (S, Text1)
If InStr (S, Text1) & gt; 0 And l & gt; 0 Then
Text2=Mid (S, InStr (S, Text1) + 36, l - 36)
End the If
End Sub

Private Sub Timer1_Timer ()
Command3_Click
Command4_Click
End Sub

CodePudding user response:

Should be the problem of the HTTP request message head wrong.
Need to be caught, imitate the browser to add message header.

CodePudding user response:

Attention should be paid to several problems:
1, the responseText XMLHTTP and responseBody or differentiated, responseBody is the most complete data,
2, VB type String can only hold 64 k within the text, beyond the part will be cut off, to deal with beyond the text of 64 k, may use byte array processing
3, page code also should pay attention to, now many websites are not gb2312 encoding, processing time need to transform coding
You can refer to this article:
VB to analysis the content of more than 64 k (based on XMLHTTP and byte array processing)

CodePudding user response:

Some sites are blocked your collection, baidu, I understand the acquisition limited frequently will definitely give you the IP, you try to keep press F5, advice plus time interval, or change the IP on a regular basis
  • Related