MatchCollection not working with me !!

basta

New member
Joined
Feb 11, 2013
Messages
3
Programming Experience
Beginner
Hi,

I want to made program to get some text from web page source .

For Ex. GameZConnect | User Profile
I want to get this from source

dqG17ji.png


Line 101, var uid_crr_user = "u0Seo1y2DcbYoU8oKUNpJ227";
I want only u0Seo1y2DcbYoU8oKUNpJ227


My code:
VB.NET:
Imports System.NetImports System.IOImports System.Text.RegularExpressions
Public Class Form1
    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork        Try
            Dim rq As HttpWebRequest = HttpWebRequest.Create("http://gamezconnect.com/" + Me.TextBox1.Text)            Dim rs As HttpWebResponse = rq.GetResponse()            Dim sr As StreamReader = New StreamReader(rs.GetResponseStream())            Dim strHtml As String = sr.ReadToEnd()            sr.Close()            rs.Close()
            Dim Mt2 As MatchCollection = Regex.Matches(strHtml, "(var uid_crr_user = .*;)", RegexOptions.IgnoreCase)            If Mt2.Count > 0 Then                TextBox2.Text = Mt2.Item(0).Value.Split(" = ")(1).Replace(";", "")            End If
        Catch

        End Try    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click        BackgroundWorker1.RunWorkerAsync()    End SubEnd Class


Help me plz.

Thanks.
 
You can group only that value in pattern with paranthesis:
        Dim m = Regex.Match(html, "var uid_crr_user = ""(.*?)"";")
        If m.Groups(1).Success Then
            Dim v = m.Groups(1).Value 'v= u0Seo1y2DcbYoU8oKUNpJ227

        End If
 
Good.

But i got this error "Cross-thread operation not valid: Control 'TextBox2' accessed from a thread other than the thread it was created on."

PHP:
Dim rq As HttpWebRequest = HttpWebRequest.Create("http://gamezconnect.com/" + Me.TextBox1.Text)        
Dim rs As HttpWebResponse = rq.GetResponse()        Dim sr As StreamReader = New StreamReader(rs.GetResponseStream())        
Dim strHtml As String = sr.ReadToEnd()        
sr.Close()       
rs.Close()
Dim m = Regex.Match(strHtml, "var uid_crr_user = ""(.*?)"";")        

If m.Groups(1).Success Then            
TextBox2.Text = m.Groups(1).Value 'v= u0Seo1y2DcbYoU8oKUNpJ227
End If
 
Back
Top