From: David ‘Bombe’ Roden Date: Mon, 9 Mar 2009 23:12:09 +0000 (+0100) Subject: Add new links to core. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6c8cff3cb5a52300d182a30286a53b4ec12059db;p=arachne.git Add new links to core. --- diff --git a/src/net/pterodactylus/arachne/core/URLFetcher.java b/src/net/pterodactylus/arachne/core/URLFetcher.java index df8180f..0b4cb47 100644 --- a/src/net/pterodactylus/arachne/core/URLFetcher.java +++ b/src/net/pterodactylus/arachne/core/URLFetcher.java @@ -2,6 +2,7 @@ package net.pterodactylus.arachne.core; import java.io.IOException; import java.io.InputStream; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.logging.Level; @@ -69,14 +70,21 @@ class URLFetcher implements Runnable, ParserListener { * {@inheritDoc} */ public void parsedLink(InputStream inputStream, String linkTarget, String linkTitle, String linkText) { - System.out.println("Found link to “" + linkTarget + "” named “" + linkText + "” or “" + linkTitle + "”."); + URL newLink = null; + try { + newLink = new URL(url, linkTarget); + core.addPage(newLink); + } catch (MalformedURLException mue1) { + logger.log(Level.WARNING, "Could not create URL from “" + url + "” and “" + linkTarget + "”.", mue1); + } catch (IllegalArgumentException iae1) { + logger.log(Level.WARNING, "Could not add “" + newLink + "” to core queue.", iae1); + } } /** * {@inheritDoc} */ public void parsedTitle(InputStream inputStream, String title) { - System.out.println("Found title “" + title + "”."); } }