-
March 23rd, 2012, 07:29 PM
#1
Need help with loops
Hi guys,
I need your help with the loop. When I load a form to set up the timer to one second, it will get access to my site via httpwebrequest. It will look for the html tags called "mystrings1" and it will look for the matches pattern in the same line as the mystrings1 tags to see if the tags has "<span mystrings2>"Enabled"", then it will display the messagebox when each matches are found.
Code:
Public Sub timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs)
timer1.Enabled = False
timer1.Stop()
Dim form1 As Form1 = TryCast(Owner, Form1)
Try
Dim URL1 As String = "http://www.mysite.com/myscript.php?user=test&pass=test"
Dim request1 As HttpWebRequest = CType(WebRequest.Create(URL1), HttpWebRequest)
Dim response1 As HttpWebResponse = CType(request1.GetResponse(), HttpWebResponse)
Dim reader1 As New StreamReader(response1.GetResponseStream())
Dim str1 As String = reader1.ReadToEnd()
Dim pattern1 As String = "(<p\sid='mystrings1'>(?<mystrings1>[^<>]+)</p>.*<span\sid=\""test\"">Enabled"")"
Dim matches1 As MatchCollection = Regex.Matches(str1, pattern1)
Dim m1 As Match = Regex.Match(str1, pattern1)
For Each x1 As Match In matches1
Dim StrArr1() As String = x1.Value.ToString().Split()
MessageBox.Show(x1.Groups("mystrings1").Value)
Next x1
Catch ex As Exception
End Try
End Sub
What my code are doing is when they get access to my site, they will look for the tags called "mystrings1" and it will look for the matches pattern in the same line as the mystrings1 tags to see if the tags has "<span mystrings2>"Enabled"", then it will only display the messagebox once at a time when more than one matches are found.
I have already set the loops using with For Each x1 As Match In matches1 statement.
Do you know why the loops isn't working and are there a way to fix the problem?
Thanks,
Mark
-
March 25th, 2012, 06:38 PM
#2
-
March 26th, 2012, 06:02 PM
#3
Re: Need help with loops
I have tried it, but it will make no difference. What I am trying to do is to reads the php source from my website to see if the strings in the mystrings2 tags have got the text called "enabled"while each matches are found, then extract the strings from mystrings1 tags and display the messagebox. However, the messagebox are only displaying once when I have got more than one matches.
Any idea how I can find the strings in the mystrings2 tags to see if each matches are found?
-
March 27th, 2012, 12:34 PM
#4
Re: Need help with loops
Create a SERVICE that runs on your server. Send it a parameter and have it reply with Not Found, or spits back the value returned. It should be able to access the code ON the server
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|