public void crawl() {
        while (!toProcess.isEmpty()) {
            String url = toProcess.pollFirst();
            URL pageUrl;
            Reader reader;
            PageFetcher.Result result;
            try {
                pageUrl = new URL(url);
                result = fetcher.fetch(pageUrl);
                reader = result.getReader();
            } catch (IOException | UnsupportedContentTypeException e) {
                // Do nothing
                continue;
            }

            Set<String> links;
            try {
                links = parser.parse(pageUrl, reader, result.getEncoding());
            } catch (IOException e) {
                // Do nothing
                continue;
            }
            for (String link : links) {
                if (obtained.size() >= maxToObtain) {
                    return;
                }
                if (obtained.add(link)) {
                    toProcess.addLast(link);
                }
            }
        }
    }