1.如何用vb得到网页的源码源代码
2.VB如何获取webbrowser源码指定文本
3.VBä¸çWebBrowser1
如何用vb得到网页的源代码
1 先加载网页:
Private Sub Form_Load()
WebBrowser1.Navigate "/question/.html"
End Sub
2 加载完成后取字符串到文本框:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim doc As Object, objhtml As Object
Dim strhtml As String
On Error GoTo errorsub
Me.Caption = WebBrowser1.LocationName & " 加载完成"
If MaxWebNum <= 0 Then
Set doc = WebBrowser1.Document
Set objhtml = doc.body.createtextrange()
If Not IsNull(objhtml) Then
strhtml = WebBrowser1.Document.body.innertext
Text1.Text = strhtml
End If
End If
Exit Sub
errorsub:
Text1.Text = "错误!!源码统计模块源码!源码ERP表单源码"
End Sub
VB如何获取webbrowser源码指定文本
先引用正则库,源码汇率源码 php然后编写如下代码,源码评委评分源码其中html的源码get缓存源码值替换为你问题中的html源码。Private Sub Form_Load()
Dim html As String
html = "<li><em>经验值</em></li><li><em>金币数</em></li>"
ExpeValue = FindFirstGroup("<em>经验值</em>(\d+)</li>",源码 html)
CoinValue = FindFirstGroup("<em>金币数</em>(\d+)</li>", html)
MsgBox "经验值为" & ExpeValue
MsgBox "金币值为" & CoinValue
End Sub
Private Function FindFirstGroup(pattern As String, src As String) As String
Dim re As RegExp
Set re = New RegExp
With re
.pattern = pattern
Set Matches = .Execute(src)
If Matches.Count = 0 Then
FindFirstGroup = ""
Else
FindFirstGroup = Matches(0).SubMatches(0)
End If
End With
End Function
VBä¸çWebBrowser1
è¯è¯è¿ä¸ªåæ³ï¼
建ç«ä¸ä¸ªwb(0),Visible=False
(WBæ¯WebBrowseræ§ä»¶æ°ç»ââåªè¦è®¾ç½®å®çIndex=0è¿æVisible=Falseå³å¯ï¼
代ç æ¯ï¼
Sub InitWB(Optional Update As Boolean=False)
If Update Then Unload(wb(1))
Load wb(1)
wb(1).visible = true
wb(1).left = 0
wb(1).top = 0
wb(1).width =
wb(1).height = 'åå§åå®ç尺寸åæ ä½ èªå·±å
'å¦æè¿æå ¶ä»å±æ§è®¾ç½®è¿éå ä¸
End Sub
Private Sub Form_Load()
InitWB
End Sub
å¦æè¦æ´æ°ï¼è°ç¨è¯å¥Call InitWB(true)
è¿æ ·åºè¯¥æ¯å¯ä»¥çã
ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼
建ç«ä¸ä¸ªWebrowser1,å½å为wbï¼è®¾ç½®ä»çå±æ§index=0
ç¶åç¨ä¸é¢ä»£ç