Hi im trying to crawl some little info from a website but i cant seem to get out the information i want.
Cant can the pattern to work
String regex = "<span class=\"C\">(.*?)</span>";
This is how the html looks like
<span class="C"> 4. Middlesbr-Bolton 5-1 </span>
Would appreciate if someone could help
Best Regards
Jawn
Code:
import java.io.*;
import java.net.*;
import java.util.regex.*;
class Stryktips {
public static void main(String[] args) throws Exception{
URL u = new URL("http://svt.se/svttext/web/pages/551.html");
URLConnection uc = u.openConnection();
uc.setDoInput(true);
uc.connect();
BufferedReader in = new BufferedReader (new InputStreamReader(uc.getInputStream()));
String i = in.readLine();
//String regex = "class=\"C\">(.*?)</span>";
//String regex = "([0-9]{1,4})";
String regex = "<span class=\"C\">(.*?)</span>";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(i);
while (matcher.find()) {
System.out.println("Found a match: " + matcher.group());
System.out.println("Start position: " + matcher.start());
System.out.println("End position: " + matcher.end());
}
}
}
Cant can the pattern to work
String regex = "<span class=\"C\">(.*?)</span>";
This is how the html looks like
<span class="C"> 4. Middlesbr-Bolton 5-1 </span>
Would appreciate if someone could help
Best Regards
Jawn






