VB提取网页中的链接地址?

具体情况大家进http://zczy.5tf.net/wenti/01.html看看~

v

楼上的.....

你是用了WebBrowser控件~....并不是针对IE来的 `

代码如下:

'窗体
Private Sub Command1_Click()
Text1.Text = GetWebSite(FindWindow("IEFrame", vbNullString))
End Sub

'模块
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
'Declare Function GetLastError Lib "kernel32" () As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
'Declare Function ReleaseCapture Lib "user32" () As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

Const WM_GETTEXT = &HD
Type POINTAPI
x As Long
y As Long
End Type

'-
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Const WM_QUIT = &H12
Public Const WM_CLOSE = &H10
Dim A, B, C, D, E
Dim LrMem(1 To 5) As Long
Dim TP As Long
Public Function GetWebSite(IehWnd As Long) As String
Dim Ws As Long, Sa As Long
Ws = FindWindow("IEFrame", vbNullString)
Sa = GetIeEdit(Ws)
GetWebSite = WMGETTEXT(Sa)

End Function
Public Function GetIeEdit(IehWnd As Long) As Long
Dim Aa As Long

If IehWnd = 0 Then Exit Function
Aa = FindWindowEx(IehWnd, 0, "WorkerW", vbNullString)
If Aa = 0 Then Exit Function
Aa = FindWindowEx(Aa, 0, "ReBarWindow32", vbNullString)
If Aa = 0 Then Exit Function

Aa = FindWindowEx(Aa, 0, "ComboBoxEx32", vbNullString)
If Aa = 0 Then Exit Function

Aa = FindWindowEx(Aa, 0, "ComboBox", vbNullString)
If Aa = 0 Then Exit Function

Aa = FindWindowEx(Aa, 0, "Edit", vbNullString)

If Aa = 0 Then Exit Function

GetIeEdit = Aa

End Function
Public Function WMGETTEXT(EdithWnd As Long) As String
Dim EditContent As String
EditContent = Space(65536)
SendMessage EdithWnd, WM_GETTEXT, 65536, EditContent
WMGETTEXT = Trim(EditContent)
End Function
Public Function FindIEWindow() As Long
FindIEWindow = FindWindow("IEFrame", vbNullString)

End Function
温馨提示:内容为网友见解,仅供参考
第1个回答  2008-08-06
用Microsoft Internet Controls部件中的WebBrowser控件链接网页后,看下面操作,比如我连接百度然后获取百度的网页点击地址。
Private Sub Form_Load()
WebBrowser1.Navigate "www.baidu.com"
End Sub

Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Text1.Text = URL
End Sub

vb 获取一个网页内的链接和链接名称
1、先将网页另存到本机,假设文件名为ABC.HTM,保存在C盘根目录下;2、用VB读取存好的ABC.HTM文件的全部内容到一个变量或文本框;3、用搜索函数InStr()和取字串的函数Mid()来抽取出介于“>”和“<\/A>”之间的文本,就是超链接的文字;抽取“href=”和空格之间的内容,就是链接的URL。代码如下...

vb怎么提取网页中的链接?
Private Sub Command1_Click()Dim vTag, vDoc Dim AllCount, i List1.Clear Set vDoc = WebBrowser1.Document.All AllCount = vDoc.Length MsgBox (AllCount)For i = 0 To AllCount - 1 Debug.Print vDoc.Item(i)If UCase(vDoc.Item(i).TagName) = "A" Then '?òμ?URL vTag =...

vb 提取网页链接地址
126邮箱用到了许多框架,而且是用javascipt所写的函数随机调用的。直接提取框架页是不行的,必须单独打开要提取的页面才可以。你在信内容的页面上按鼠标右键,单击属性,在弹出的窗口中复制地址,然后再用WebBrowser打开地址就可以抓取了。地址举例:http:\/\/cwebmail.mail.126.com\/js5\/read\/readhtml.jsp...

VB提取网页中的链接地址?
Public Function FindIEWindow() As Long FindIEWindow = FindWindow("IEFrame", vbNullString)End Function

vb编程抓取网页url地址
可以先用WebBrowser之类的控件,将源码获取了,再利用字符串分析功能查找到相应的地址,存储到txt文件里就可以了。如果要是刚开始接触vb可能麻烦点,不过每项功能都可以在网上和帮助上找到源码的。

用VB提取网页中的链接地址
获得网页中的超链接网址对一些网络编程很有用处,很多朋友都不会用,今天我就交给大家怎么才能在VB6.0中实现这个功能,首先新建一个工程,加入webbrowser和scriptlet控件(引用部件Microsoft HTMl object Library添加一个Listbox控件(用于存放读出的网址)命名为(listurl),个textbox()控件用于打开网址命名为txt...

vb获取网页链接地址
先获得网页的源码,然后用Open打开,查找含有 http:\/\/www.xxxx.com\/xxxx\/dd.html 等连接.Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal ...

vb获取网页页数的链接?
一、定义2个数组,比方说:dim A(0 to 999)as integer,B (0 to 999) as integer二、然后再赋值:for i = 0 to 999 step 1 a(i)=i+1 b(i)=i+1next三、把数组带入链接中:baidu.com\/abc-str(A(i))-str(B(i)).html ...

vb WebBrowser网页判断后提取
提取所有链接倒可以,但手机号码和邮件地址要以网页而定。提取所有链接代码:点击按钮后,所有网址都保存在d:\\1.txt里 Private Sub Command1_Click()Open "d:\\1.txt" For Output As #1 Close Dim x As Long Dim y As String For x = 0 To WebBrowser1.Document.links.length - 1 Print ...

VB 如何提取网页源码中的所有url链接
正则表达式(]*>.+?)提取所有满足条件的字符串到array

相似回答
大家正在搜