@SuppressWarnings("unchecked")
    private List<IResource> fetchResources(HtmlPage page) throws MalformedURLException {
        List<IResource> resources = new ArrayList<>();
        for (HtmlScript script : (List<HtmlScript>) page.getByXPath("/html/head/script")) {
            String src = script.getSrcAttribute();
            addResource(src, resources);
        }
        for (HtmlLink link : (List<HtmlLink>) page.getByXPath("/html/head/link")) {
            addResource(link.getHrefAttribute(), resources);
        }
        for (HtmlImage image : (List<HtmlImage>) page.getByXPath("//img")) {
            addResource(image.getSrcAttribute(), resources);
        }
        return resources;
    }