提取解析HTML&文本 [英] Extracting Parsing Html & Text
本文介绍了提取解析HTML&文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个YouTube竞争检查器,以分析竞争视频的竞争.这是用于SEO或搜索引擎优化的非常有价值的工具.
I am coding a youtube competition checker to analyze the competition of competing videos. This is a very valuable tool for SEO or search engine optimization.
我的问题是vb 2008似乎无法识别< p>标签或其元素.
Well my issue is that it seem that vb 2008 doesn't recognize the html of the <p> tag or it's element.
这是我尝试使用的代码:
Here is the code that I was trying to use:
Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("p")
For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("class").Contains("num-results") Then
RichTextBox1.Text += curElement.GetAttribute("innerText") & vbCrLf
End If
Next
推荐答案
Hi Inforequester123 ,
您可以改为获取页面的源,然后将其拆分.
You can instead get the source of the page and then split it.
例如:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim o As Object
Dim bGetAsAsync As Boolean
Dim a As String
o = CreateObject("Microsoft.XMLHTTP")
bGetAsAsync = False
o.open("GET", "http://www.youtube.com/results?search_query=ufo+sightings+2011&aq=f", bGetAsAsync)
o.send()
a = o.responseText
Dim x() = Split(a, "num-results")
Dim y() = Split(x(1), ">")
Dim result() = Split(y(2), "<")
RichTextBox1.Text = result(0)
End Sub
End Class
这篇关于提取解析HTML&文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文