-
Jan 8th, 2015, 08:33 AM
#1
Thread Starter
Addicted Member
Regex doesn't working
I make this regex to grab content from internet page:
Code:
Regex.Match(HTML, "'block_competition_matches', ({[\w\s"",:]+})").Groups(1).ToString
webpage.
But regex return false, what isn't correct?
-
Jan 8th, 2015, 09:28 AM
#2
Re: Regex doesn't working
After 60 posts on this forum you should know by now to include detail. "It doesn't work whats wrong" is simply expecting members to guess what parts of the data you want to capture, work out whats happening and whats going wrong. Most members will ignore threads like these.
You already know whats wrong. I's the regex pattern. How much regex have you studied? Can you please show what part of the HTMl you actually want.
-
Jan 8th, 2015, 01:52 PM
#3
Hyperactive Member
Re: Regex doesn't working
From the link given, the pattern 'block_competition_matches', doesn't exist so the entire match including the group would not exist. The closest was 16 matches to block_competition_matches, but each of those is then followed by _summary_6 which is not what your pattern is looking for. What exactly are you trying to match (not just the text you are using for HTML, but an example string from that webpage that contains what you are trying to match).
-
Jan 9th, 2015, 03:59 AM
#4
Thread Starter
Addicted Member
Re: Regex doesn't working
Originally Posted by Pyth007
From the link given, the pattern 'block_competition_matches', doesn't exist so the entire match including the group would not exist. The closest was 16 matches to block_competition_matches, but each of those is then followed by _summary_6 which is not what your pattern is looking for. What exactly are you trying to match (not just the text you are using for HTML, but an example string from that webpage that contains what you are trying to match).
To give you an example clear, I in my previous code I used this:
Code:
Dim HTML As String = New WebClient().DownloadString(URLs(MetroComboBox2.SelectedIndex))
Dim URL_Params As String = "&callback_params=" & Regex.Match(HTML, "'block_competition_playerstats', ({[\w\s"",:]+})").Groups(1).ToString
MessageBox.Show(URL_Params.ToString)
How you can see, I save in HTML variable the contents of the page, so in the "URL_Params" I've the all div block of the HTML table existing in the HTML variable.
The content that i get is:
So, now i Want to catch another table available in this link.
And i make this code:
Code:
Dim HTML As String = New WebClient().DownloadString(URLs(MetroComboBox2.SelectedIndex))
Dim URL_Params As String = "&callback_params=" & Regex.Match(HTML, "'block_competition_matches_summary_6', ({[\w\s"",:]+})").Groups(1).ToString
MessageBox.Show(URL_Params.ToString)
But the regex don't catch the value but these are available on the page.
-
Jan 9th, 2015, 05:39 AM
#5
Re: Regex doesn't working
Your first post the query was block_competition_matches, but now it is block_competition_matches_summary_6. This is why i asked for you to be clear because i do't want to keep coming back and forth. This is why i also said can you please post the exact match you want from the source.
With the query text you provided
vb Code:
block_competition_matches_summary_6_match-1836425\" data-competition=13><td class=\"day no-repetition\"><span class='timestamp' data-value='1420552800' data-format='ddd'>mar<\/span><\/td><td class=\"date no-repetition\"><span class='timestamp' data-value='1420552800' data-format='dd\/mm\/yy'>06\/01\/15<\/span><\/td><td class=\"team team-a \"><a href=\"\/teams\/italy\/genoa-cfc\/1276\/\" title=\"Genoa\">Genoa<\/a><\/td>
so can you be so kindly to show me right after that query you provided is there any curly brackets.....Because there is not.
Code:
block_competition_matches_summary_6 .match-pagination {margin-bottom: 0.7em;}
Now is the line you want to match because you have seemed to ignore ".match-pagination" in your matching if this is the line in question.
vb Code:
Imports System.Text.RegularExpressions Public Class Form1 Private Sub FindMatches(url As String) Dim source As String = GetPagesSource(url) If source IsNot Nothing Then Dim pattern As String = "(?<=summary_6 \.match-pagination ).+?(?=<)" Dim rx As New Regex(pattern) MessageBox.Show("&callback_params=" & rx.Match(source).Value) End If End Sub Private Function GetPagesSource(url As String) As String Dim source As String = Nothing Using wClient As New Net.WebClient() Try source = wClient.DownloadString(New Uri(url)) Catch ex As Exception ' handle gracefully End Try End Using Return source End Function End Class
This is why i previously asked for a full and clear description. Just because something is clear to you it might to be to us. Each member who asks a question time is important to us. His/hers problem is important to us. If we spend lots of time going back and forth it takes time away from others. We don't like guess work.
-
Jan 10th, 2015, 10:20 AM
#6
Thread Starter
Addicted Member
Re: Regex doesn't working
Originally Posted by ident
Your first post the query was block_competition_matches, but now it is block_competition_matches_summary_6. This is why i asked for you to be clear because i do't want to keep coming back and forth. This is why i also said can you please post the exact match you want from the source.
With the query text you provided
vb Code:
block_competition_matches_summary_6_match-1836425\" data-competition=13><td class=\"day no-repetition\"><span class='timestamp' data-value='1420552800' data-format='ddd'>mar<\/span><\/td><td class=\"date no-repetition\"><span class='timestamp' data-value='1420552800' data-format='dd\/mm\/yy'>06\/01\/15<\/span><\/td><td class=\"team team-a \"><a href=\"\/teams\/italy\/genoa-cfc\/1276\/\" title=\"Genoa\">Genoa<\/a><\/td>
so can you be so kindly to show me right after that query you provided is there any curly brackets.....Because there is not.
Code:
block_competition_matches_summary_6 .match-pagination {margin-bottom: 0.7em;}
Now is the line you want to match because you have seemed to ignore ".match-pagination" in your matching if this is the line in question.
vb Code:
Imports System.Text.RegularExpressions Public Class Form1 Private Sub FindMatches(url As String) Dim source As String = GetPagesSource(url) If source IsNot Nothing Then Dim pattern As String = "(?<=summary_6 \.match-pagination ).+?(?=<)" Dim rx As New Regex(pattern) MessageBox.Show("&callback_params=" & rx.Match(source).Value) End If End Sub Private Function GetPagesSource(url As String) As String Dim source As String = Nothing Using wClient As New Net.WebClient() Try source = wClient.DownloadString(New Uri(url)) Catch ex As Exception ' handle gracefully End Try End Using Return source End Function End Class
This is why i previously asked for a full and clear description. Just because something is clear to you it might to be to us. Each member who asks a question time is important to us. His/hers problem is important to us. If we spend lots of time going back and forth it takes time away from others. We don't like guess work.
Sorry, I missed the link, this is correct link:
http://it.soccerway.com/national/ita...season/r27139/
this is the table:
Thank you for the response.
-
Jan 10th, 2015, 11:40 AM
#7
Re: Regex doesn't working
That is a link and yes that is a table. But you have not said WHAT line you want to match.
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
|