Update nikiroo-utils, use it, fix 2 bugs:
[gofetch.git] / src / be / nikiroo / gofetch / support / LWN.java
index dba4c3bfa922f684729352baa2d438e075c1ac88..27b539c5e42ffa6bec08c5c4e689377bf3742068 100644 (file)
@@ -31,12 +31,12 @@ public class LWN extends BasicSupport {
                List<Story> list = new ArrayList<Story>();
 
                URL url = new URL("https://lwn.net/");
-               InputStream in = open(url);
+               InputStream in = downloader.open(url);
                Document doc = DataUtil.load(in, "UTF-8", url.toString());
-               Elements stories = doc.getElementsByClass("pure-u-1");
-               for (Element story : stories) {
-                       Elements titles = story.getElementsByClass("Headline");
-                       Elements listings = story.getElementsByClass("BlurbListing");
+               Elements articles = doc.getElementsByClass("pure-u-1");
+               for (Element article : articles) {
+                       Elements titles = article.getElementsByClass("Headline");
+                       Elements listings = article.getElementsByClass("BlurbListing");
                        if (titles.size() == 0) {
                                continue;
                        }
@@ -74,7 +74,7 @@ public class LWN extends BasicSupport {
                        String id = "";
                        String intUrl = "";
                        String extUrl = "";
-                       for (Element idElem : story.getElementsByTag("a")) {
+                       for (Element idElem : article.getElementsByTag("a")) {
                                // Last link is the story link
                                intUrl = idElem.absUrl("href");
                                pos = intUrl.indexOf("#Comments");
@@ -99,7 +99,7 @@ public class LWN extends BasicSupport {
                // Do not try the paid-for stories...
                if (!story.getTitle().startsWith("[$]")) {
                        URL url = new URL(story.getUrlInternal());
-                       InputStream in = open(url);
+                       InputStream in = downloader.open(url);
                        Document doc = DataUtil.load(in, "UTF-8", url.toString());
                        Elements fullContentElements = doc
                                        .getElementsByClass("ArticleText");
@@ -167,7 +167,7 @@ public class LWN extends BasicSupport {
        }
 
        private List<String> toLines(Element element) {
-               return toLines(element, new QuoteProcessor() {
+               return toLines(element, new BasicElementProcessor() {
                        @Override
                        public String processText(String text) {
                                while (text.startsWith(">")) { // comments