1

Actually I have full html source code of the website ..I want to extract data between the specific div tag here is my code..

Dim request As WebRequest = WebRequest.Create("https://www.crowdsurge.com/store/index.php?storeid=1056&menu=detail&eventid=41815")
    Using response As WebResponse = request.GetResponse()
        Using reader As New StreamReader(response.GetResponseStream())
            html = reader.ReadToEnd()
        End Using
    End Using

    Dim pattern1 As String = "<div class = ""ei_value ei_date"">(.*)"
    Dim m As Match = Regex.Match(html, pattern1)
    If m.Success Then
        MsgBox(m.Groups(1).Value)
    End If
2
  • Might be worth looking at the HtmlAgilityPack, as it will save you a whole lot of pain. Commented Jul 15, 2014 at 10:21
  • I also used html agility pack but i was not able to extract data from div ..then I have to use this...could you please tell me how i can extract div data using html agility pack Commented Jul 15, 2014 at 10:24

2 Answers 2

2

An easier approach for parsing HTML (especially from a source that you don't control) is to use the HTML Agility Pack, which would allow you to do something a little like:

Dim req As WebRequest = WebRequest.Create("https://www.crowdsurge.com/store/index.php?storeid=1056&menu=detail&eventid=41815")
Dim doc As New HtmlDocument()
Using res As WebResponse = req.GetResponse()
    doc.Load(res.GetResponseStream())
End Using

Dim nodes = doc.DocumentNode.SelectNodes("//div[@class='ei_value ei_date']")
If nodes IsNot Nothing Then
    For Each var node in nodes
        MsgBox(node.InnerText)
    Next
End IF

(I've assumed Option Infer)

Sign up to request clarification or add additional context in comments.

Comments

0

Try that:

Dim pattern1 As String = "<div class\s*=\s*""ei_value ei_date"">(.*?)</div>"

or

Dim pattern1 As String = "<div class=""ei_value ei_date"">(.*?)</div>"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.