// Path: scrapper/src/model/Match.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class Match {
// 
// 	@JsonProperty
// 	private int matchNum;
// 
// 	@JsonProperty
// 	@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm", timezone="GMT+2")
// 	private ZonedDateTime dateTime;
// 
// 	@JsonProperty
// 	private String group;
// 
// 	@JsonProperty
// 	private String stadium;
// 
// 	@JsonProperty
// 	private String homeTeamName;
// 
// 	@JsonProperty
// 	private Integer homeTeamWinnerFrom;
// 
// 	@JsonProperty
// 	private String awayTeamName;
// 
// 	@JsonProperty
// 	private Integer awayTeamWinnerFrom;
// 
// 	public Match(int matchNum, ZonedDateTime dateTime, String group, String stadium, String homeTeamName, String awayTeamName) {
// 		this.matchNum = matchNum;
// 		this.dateTime = dateTime;
// 		this.group = group;
// 		this.stadium = stadium.trim();
// 		this.homeTeamName = homeTeamName.trim();
// 		this.awayTeamName = awayTeamName.trim();
// 	}
// 
// 	public Match(int matchNum, ZonedDateTime dateTime, String group, String stadium, int homeTeamWinnerFrom, int awayTeamWinnerFrom) {
// 		this.matchNum = matchNum;
// 		this.dateTime = dateTime;
// 		this.group = group;
// 		this.stadium = stadium;
// 		this.homeTeamWinnerFrom = homeTeamWinnerFrom;
// 		this.awayTeamWinnerFrom = awayTeamWinnerFrom;
// 	}
// 
// 	public int getMatchNum() {
// 		return matchNum;
// 	}
// 
// 	public void setMatchNum(int matchNum) {
// 		this.matchNum = matchNum;
// 	}
// 
// 	public ZonedDateTime getDateTime() {
// 		return dateTime;
// 	}
// 
// 	public void setDateTime(ZonedDateTime dateTime) {
// 		this.dateTime = dateTime;
// 	}
// 
// 	public String getGroup() {
// 		return group;
// 	}
// 
// 	public void setGroup(String group) {
// 		this.group = group;
// 	}
// 
// 	public String getStadium() {
// 		return stadium;
// 	}
// 
// 	public void setStadium(String stadium) {
// 		this.stadium = stadium;
// 	}
// 
// 	public String getHomeTeamName() {
// 		return homeTeamName;
// 	}
// 
// 	public void setHomeTeamName(String homeTeamName) {
// 		this.homeTeamName = homeTeamName;
// 	}
// 
// 	public Integer getHomeTeamWinnerFrom() {
// 		return homeTeamWinnerFrom;
// 	}
// 
// 	public void setHomeTeamWinnerFrom(Integer homeTeamWinnerFrom) {
// 		this.homeTeamWinnerFrom = homeTeamWinnerFrom;
// 	}
// 
// 	public String getAwayTeamName() {
// 		return awayTeamName;
// 	}
// 
// 	public void setAwayTeamName(String awayTeamName) {
// 		this.awayTeamName = awayTeamName;
// 	}
// 
// 	public Integer getAwayTeamWinnerFrom() {
// 		return awayTeamWinnerFrom;
// 	}
// 
// 	public void setAwayTeamWinnerFrom(Integer awayTeamWinnerFrom) {
// 		this.awayTeamWinnerFrom = awayTeamWinnerFrom;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Match{" +
// 				"matchNum=" + matchNum +
// 				", dateTime=" + dateTime +
// 				", group='" + group + '\'' +
// 				", stadium='" + stadium + '\'' +
// 				", homeTeamName='" + homeTeamName + '\'' +
// 				", homeTeamWinnerFrom=" + homeTeamWinnerFrom +
// 				", awayTeamName='" + awayTeamName + '\'' +
// 				", awayTeamWinnerFrom=" + awayTeamWinnerFrom +
// 				'}';
// 	}
// }


import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import model.Match;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package wc2018.scrapper;



public class WC2018Scrapper {

    public String getName(Element nameElement) throws IOException {
        Elements name = nameElement.select("[itemprop=name]");
        String teamName = name.select("a").isEmpty() ? name.text() : name.select("a").text();
        Elements teamFlag = nameElement.select(".flagicon img");
        if (!teamFlag.isEmpty()) {
            String flagSet = teamFlag.first().attr("srcset");
            Path flagsDirectory = Paths.get("flags");
            Files.createDirectories(flagsDirectory);
        }
        return teamName;
    }

    public void scrapMatches() throws IOException {

        Document doc = Jsoup.connect("https://en.wikipedia.org/wiki/2018_FIFA_World_Cup").get();

        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JavaTimeModule());

// Path: scrapper/src/model/Match.java
// @JsonInclude(JsonInclude.Include.NON_NULL)
// public class Match {
// 
// 	@JsonProperty
// 	private int matchNum;
// 
// 	@JsonProperty
// 	@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm", timezone="GMT+2")
// 	private ZonedDateTime dateTime;
// 
// 	@JsonProperty
// 	private String group;
// 
// 	@JsonProperty
// 	private String stadium;
// 
// 	@JsonProperty
// 	private String homeTeamName;
// 
// 	@JsonProperty
// 	private Integer homeTeamWinnerFrom;
// 
// 	@JsonProperty
// 	private String awayTeamName;
// 
// 	@JsonProperty
// 	private Integer awayTeamWinnerFrom;
// 
// 	public Match(int matchNum, ZonedDateTime dateTime, String group, String stadium, String homeTeamName, String awayTeamName) {
// 		this.matchNum = matchNum;
// 		this.dateTime = dateTime;
// 		this.group = group;
// 		this.stadium = stadium.trim();
// 		this.homeTeamName = homeTeamName.trim();
// 		this.awayTeamName = awayTeamName.trim();
// 	}
// 
// 	public Match(int matchNum, ZonedDateTime dateTime, String group, String stadium, int homeTeamWinnerFrom, int awayTeamWinnerFrom) {
// 		this.matchNum = matchNum;
// 		this.dateTime = dateTime;
// 		this.group = group;
// 		this.stadium = stadium;
// 		this.homeTeamWinnerFrom = homeTeamWinnerFrom;
// 		this.awayTeamWinnerFrom = awayTeamWinnerFrom;
// 	}
// 
// 	public int getMatchNum() {
// 		return matchNum;
// 	}
// 
// 	public void setMatchNum(int matchNum) {
// 		this.matchNum = matchNum;
// 	}
// 
// 	public ZonedDateTime getDateTime() {
// 		return dateTime;
// 	}
// 
// 	public void setDateTime(ZonedDateTime dateTime) {
// 		this.dateTime = dateTime;
// 	}
// 
// 	public String getGroup() {
// 		return group;
// 	}
// 
// 	public void setGroup(String group) {
// 		this.group = group;
// 	}
// 
// 	public String getStadium() {
// 		return stadium;
// 	}
// 
// 	public void setStadium(String stadium) {
// 		this.stadium = stadium;
// 	}
// 
// 	public String getHomeTeamName() {
// 		return homeTeamName;
// 	}
// 
// 	public void setHomeTeamName(String homeTeamName) {
// 		this.homeTeamName = homeTeamName;
// 	}
// 
// 	public Integer getHomeTeamWinnerFrom() {
// 		return homeTeamWinnerFrom;
// 	}
// 
// 	public void setHomeTeamWinnerFrom(Integer homeTeamWinnerFrom) {
// 		this.homeTeamWinnerFrom = homeTeamWinnerFrom;
// 	}
// 
// 	public String getAwayTeamName() {
// 		return awayTeamName;
// 	}
// 
// 	public void setAwayTeamName(String awayTeamName) {
// 		this.awayTeamName = awayTeamName;
// 	}
// 
// 	public Integer getAwayTeamWinnerFrom() {
// 		return awayTeamWinnerFrom;
// 	}
// 
// 	public void setAwayTeamWinnerFrom(Integer awayTeamWinnerFrom) {
// 		this.awayTeamWinnerFrom = awayTeamWinnerFrom;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "Match{" +
// 				"matchNum=" + matchNum +
// 				", dateTime=" + dateTime +
// 				", group='" + group + '\'' +
// 				", stadium='" + stadium + '\'' +
// 				", homeTeamName='" + homeTeamName + '\'' +
// 				", homeTeamWinnerFrom=" + homeTeamWinnerFrom +
// 				", awayTeamName='" + awayTeamName + '\'' +
// 				", awayTeamWinnerFrom=" + awayTeamWinnerFrom +
// 				'}';
// 	}
// }


// Path: scrapper/src/wc2018/scrapper/WC2018Scrapper.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import model.Match;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

package wc2018.scrapper;



public class WC2018Scrapper {

    public String getName(Element nameElement) throws IOException {
        Elements name = nameElement.select("[itemprop=name]");
        String teamName = name.select("a").isEmpty() ? name.text() : name.select("a").text();
        Elements teamFlag = nameElement.select(".flagicon img");
        if (!teamFlag.isEmpty()) {
            String flagSet = teamFlag.first().attr("srcset");
            Path flagsDirectory = Paths.get("flags");
            Files.createDirectories(flagsDirectory);
        }
        return teamName;
    }

    public void scrapMatches() throws IOException {

        Document doc = Jsoup.connect("https://en.wikipedia.org/wiki/2018_FIFA_World_Cup").get();

        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JavaTimeModule());

        List<Match> matches = new ArrayList<>();