张彬彬是哪里人:我想用vb得到网页的源代码?

来源:百度文库 编辑:高校问答 时间:2024/05/04 05:16:01
如题,你高手指点。或给出源代码(引用什么控件等)

非常感谢
晕,,,我不要查看源吗。我需要的是用 visual basic做一个程序,打开网页的同时得到网页的源代码。

在窗体中添加控件:
按钮控件 name="cmdCode"
文本框控件 name="txtUrl"
添加两个外部控件(VB自带)
Microsoft Internet Transfer Control 6.0
默认命名为"Inet1"
Microsoft Rich Textbox Control 6.0
命名为"rtfCode"

在窗体代码
Private Sub cmdGetCode_Click()
Dim bCode() As Byte
Dim sTmp As String
Dim i As Integer
On Error Resume Next
bCode = Inet1.OpenURL(txtUrl, 1)
sTmp = ""
For i = 0 To UBound(bCode) - 1
sTmp = sTmp & Chr(bCode(i))

Next i
rtfCode.Text = sTmp
End Sub

OK 搞定,给我红旗 :)

<a href="view-source:http://www.sina.com.cn">查看源代码</a>

或者
<input type=button value=查看网页源代码
onclick=window.location = 'view-source:'+ 'http://www.sina.com.cn/'>