Home > Software engineering >  Consult ace: how to use vb to achieve, the function of the specified page is saved as a TXT text
Consult ace: how to use vb to achieve, the function of the specified page is saved as a TXT text

Time:11-03

Source,

To achieve at least equivalent to "open the specified url with Internet explorer, and then save as XXX. TXT" function,

thank you

CodePudding user response:

Liburl?

CodePudding user response:

For reference only
 Private Function StrFormat As String (s) As String 
On the Error Resume Next
Dim Buf As String
Dim StrTemp As String
Dim c As String
Dim As Long I
Dim j As Long
Dim k As Long
Dim As Long L
Buf=s
Do
L=InStr (1, Buf, "& lt; Style ", vbTextCompare)
If L & gt; 0 Then
K=InStr (L + 6, Buf, "& lt;/style>" , vbTextCompare)
If k & gt; 0 Then
Buf=Left (Buf, L - 1) + Mid (Buf, k + 8)
The Else
Buf=Left (Buf, L - 1)
The Exit Do
End the If
The Else
The Exit Do
End the If
Loop
Do
L=InStr (1, Buf, "& lt; The script, "vbTextCompare)
If L & gt; 0 Then
K=InStr (L + 7, Buf, "& lt;/script>" , vbTextCompare)
If k & gt; 0 Then
Buf=Left (Buf, L - 1) + Mid (Buf, k + 9)
The Else
Buf=Left (Buf, L - 1)
The Exit Do
End the If
The Else
The Exit Do
End the If
Loop
Buf=Replace (Buf, "& amp; Amp;" , & amp; "" )
Buf=Replace (Buf, "& amp; Quot;" , CRH (34))
'to replace double quotation marksBuf=Replace (Buf, "& amp; Lt;" , & lt; "" )
Buf=Replace (Buf, "& amp; Gt;" , & gt; "" )
Buf=Replace (Buf, ""," ")
Buf=Replace (Buf, & lt; "" , & lt; "" )
Buf=Replace (Buf, & gt; "" , "& gt;
")Buf=Replace (Buf, "& amp; Have spent" , "")
Buf=Replace (Buf, CRH (26), "")
Buf=Replace (Buf, CRH (10), "")
Buf=Replace (Buf, CRH (9), "")
Buf=Replace (Buf, CRH (13), "")
Buf=LTrim (Buf)
Buf=RTrim (Buf)
'you can add other replace
StrTemp=""
For I=1 To Len (Buf)
C=Mid (Buf, I, 1)
The Select Case c
Case & lt; ""
If I & lt;> 1 Then
StrTemp=StrTemp & amp; Mid (Buf, j + 1, I - j - 1)
End the If
Case & gt; ""
J=I
End the Select
Next I
L=Len (StrTemp)
Do
Buf=Replace (StrTemp, ""," ")
I=Len (Buf)
If I=L Then Exit the Do
L=I
StrTemp=Buf
Loop
StrFormat=Buf
End the Function

CodePudding user response:

 Private Sub Command1_Click () 
With CreateObject (" InternetExplorer. Application ")
. Navigate "http://bbs.csdn.net/topics/390471772"
The Do While Not. ReadyState=4
DoEvents
Loop
Open "d: \ so-and-so. TXT" For the Output As the # 1
Print # 1. The document. The innertext
Close # 1
End With
End Sub

CodePudding user response:

 
Private Sub Command1_Click ()
With CreateObject (" InternetExplorer. Application ")
The Visible=False
. Navigate "http://bbs.csdn.net/topics/390471772"
The Do While Not. ReadyState=4
DoEvents
Loop
Open "d: \ so-and-so. TXT" For the Output As the # 1
Print # 1. The document. All (" post - 394605125 "). All the tags (" td ") (1). The innertext
Close # 1
. The Quit
End With
End Sub

CodePudding user response:

The
reference 3 floor allowing response:
 Private Sub Command1_Click () 
With CreateObject (" InternetExplorer. Application ")
. Navigate "http://bbs.csdn.net/topics/390471772"
The Do While Not. ReadyState=4
DoEvents
Loop
Open "d: \ so-and-so. TXT" For the Output As the # 1
Print # 1. The document. The innertext
Close # 1
End With
End Sub

A little mistake, Print # 1,. The document. The innertext should be:
Print # 1, the document. The body. The innertext

CodePudding user response:

Vb own winsock control, sending HTTP command string gets web source flow
  • Related