VB.NET搜索网站的文本并放入textbox1.text

时间:2016-12-12 01:25:19

标签: vb.net web-scraping

我尝试在网站上搜索特定词组,然后将该词组添加到textbox.text

这是我现在的代码,但它不起作用:

 Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("DIV")
    For Each curElement As HtmlElement In theElementCollection
        If curElement.GetAttribute("classname") = "alert alert-warning ng-binding ng-scope" Then
            If curElement.OuterHtml.Contains("No Flex Visit could be found.") Then
                txtMessage.Text = curElement.InnerText
            End If
        Else
        End If
    Next

我需要抓取的网址摘要:



<div ng-controller="FlexVisitController" class="ng-scope">
<!-- ngInclude: '/ng/flexVisit/views/flexVisitListView.htm?201612080346' -->
<div ng-include="'/ng/flexVisit/views/flexVisitListView.htm?201612080346'" class="ng-scope">
<!-- ngIf: flexVisitList.length == 0 -->
<div class="alert alert-warning ng-binding ng-scope" role="alert" ng-if="flexVisitList.length == 0">
	No Flex Visit could be found.
</div>
<!-- end ngIf: flexVisitList.length == 0 -->
<!-- ngRepeat: project in flexVisitList -->
</div>
&#13;
&#13;
&#13;

所以,上面的网址表示如果flexVisitList0,则显示消息:&#34;无法找到Flex访问。&#34;

我想要完成的是如果此消息在网站上,则添加到文本框中。

由于

乍得

0 个答案:

没有答案