2个回答
展开全部
不用知道太多,最好会正则表达式,那样会简单点。要了解HTML语言,最起码知道<a>...</a>是链接标志,至于VB怎么读取网页和处理字符串是必须知道的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
楼上的.....
你是用了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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询