求助:怎么得到网页的源代码,要完整的

2024-12-14 10:28:30
推荐回答(5个)
回答1:

其实有很多方法,常用的就是点击右键,查看源代码,得到的就是很完整的了!

还有就是从浏览器中有一项是代码元的,你可以打开就看的到了。但是要遨游的2.0版才有!

如果还有不明白,可以联系!

回答2:

还要说的再清楚一些,比如,你要 一个在线商店的源码,
你可以搜 "vb源码 在线商店"
===============================
Private Sub Command1_Click()
Dim hInternetSession As Long
Dim hUrlFile As Long
Dim sReadBuffer As String * 4096 ' Grab 4k at a time
Dim sBuffer As String
Dim lNumberOfBytesRead As Long
Dim bDoLoop As Boolean

hInternetSession = InternetOpen("My VB App!", _
INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
hUrlFile = InternetOpenUrl(hInternetSession, _
"http://syg/a.asp?i=1", vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
bDoLoop = True

While bDoLoop
sReadBuffer = scBlankStr
bDoLoop = InternetReadFile(hUrlFile, sReadBuffer, _
Len(sReadBuffer), lNumberOfBytesRead)
sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
Wend

InternetCloseHandle (hUrlFile)
InternetCloseHandle (hInternetSession)

Label1.Caption = sBuffer
End Sub

=============
获取网页的源码 用 webbrowser控件的多

回答3:

在源码网站上下载,上面的方法都是运行后的显示效果的代码
不是全部的代码。如果是动态网站的话,只有在网上搜索他本身的源码。

回答4:

新建一个工程,加入一个 timer控件(interval:1000),一个command,webbrowser控件(microsoft html control),text控件

Private Sub Command1_Click()
WebBrowser1.Navigate "http://zhidao.baidu.com/question/23603742.html"
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Dim doc, objhtml As Object
Dim i As Integer
Dim strhtml As String

If Not WebBrowser1.Busy Then
Set doc = WebBrowser1.Document

i = 0
Set objhtml = doc.body.createtextrange()
If Not IsNull(objhtml) Then
Text1.Text = objhtml.htmltext
End If
Timer1.Enabled = False
End If
End Sub

回答5:

用java吧。

import java.io.*;
import java.net.*;

public class WebReader {
public static void main(String[] strings) throws Exception {
String address = "http://www.baidu.com";
URL url = new URL(address);
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
String temp;
while ((temp = br.readLine()) != null) {
System.out.println(temp);
}
}
}