Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

VS 2012 screen scrape using regular expressions not working

$
0
0
I am having trouble with a screen scrape using regular expressions. Here's the html:

<div id="container" class=" narrowContainer" >
<nav id="sitenav" class="">

<div class="noSubNav"></div>
</nav>
<div id="content" class="allGroups">
<div id="contentHead">
<div class="groupNav">
<a href="/community">Community</a> / Public Groups

</div>
</div>
<div id="contentBody" class="clearfix">

<div id="publicGroups">
<div class="section groups">
<ul class="groupList">

<li class="groupItem">
<a class="groupName" href="/group/22BGNF">
!Test
</a>
<span class="totalMembers">2 members</span>
<p class="description">

</p>
</li>


Here's my latest attempt. I need to loop through all of the groups, but for now, I am just trying to get the first one.

Code:

Public Sub ParseGroup(html As String)

        Dim source = "<div id=""container"" class="" narrowContainer"" >" & "<div id=""content"" class=""allGroups"">" _
                    & "<div id=""contentBody"" class ""clearfix"">" & "<div id=""publicGroups"">" & _
                    "<div class=""section groups"">" & "<ul class=""groupList"">" _
                    & "<li class=""groupItem\"">" & "</li>"
        'group record
        Dim pattern = "<ul class=""groupList"">"

        Dim rgx = New Regex(pattern, RegexOptions.IgnoreCase)
        Dim match = rgx.Match(source)

        If match.Success Then
            Dim data = match.Groups("data")
            Console.WriteLine(data.Value)
        Else
            TextBox2.Text = "No data"
        End If
    End Sub

I don't get the "No data" message, but the only thing written to the console is "The thread '<No Name>' (0x36c0) has exited with code 0 (0x0). "

I have also tried using LINQ.
Thanks for any suggestions!

Viewing all articles
Browse latest Browse all 27329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>