I am creating an application that takes information from another website.
And right now i´m just trying to make a test class there I am trying to get all the information I want from the website and just write it out to the system.out.
The website I get information from is: SVT Text - 552
The information I wan´t to show in my program is only the football teams in the "STRYKTIPSET" column.
I have no problem to get all the information from the HTML file. But my problem is that I don´t now hove to get only this team and not alla the others.
With the following code I get all the teams from the website:
Does anyone get any idea hove I can solve my problem in an easy way?public class Test { public static void main(String[] args) throws MalformedURLException, IOException { URL stryk = new URL("http://svt.se/svttext/web/pages/552.html"); BufferedReader in = new BufferedReader( new InputStreamReader( stryk.openStream())); String inputLine; StringBuilder inLine = new StringBuilder(); while ((inputLine = in.readLine()) != null) { inLine.append(inputLine); inLine.append("\n"); } in.close(); Pattern pattern = Pattern.compile("<span class=\"W\">.+?</span>"); Matcher matcher = pattern.matcher(inLine); while(matcher.find()) { System.out.println(matcher.group()); } } }
This is hove the result should look like:
Manch.C -Stoke
Arsenal -Aston V
Birmingh.-Fulham
Chelsea -Newcastle
Liverpool-Tottenham
Wigan -West Ham
Kalmar FF-Häcken
Malmö FF -Örebro
GAIS -Syrianska
Gefle -Djurgård.
Norrköp -IFK Göteb
Falkenb. -Åtvidab.
Ängelholm-Jönköping