From 6c8cff3cb5a52300d182a30286a53b4ec12059db Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 10 Mar 2009 00:12:09 +0100 Subject: [PATCH] Add new links to core. --- src/net/pterodactylus/arachne/core/URLFetcher.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 + "”."); } } -- 2.7.4