diff --git a/src/LICENSE.txt b/src/LICENSE.txt new file mode 100644 index 0000000..14eb731 --- /dev/null +++ b/src/LICENSE.txt @@ -0,0 +1,29 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +------------------------------------------------------------------- +talkCrawler +Copyright (c) 2018 Yuu Hayashi +http://surveyor.mydns.jp/gitbucket/git/yuu/talkCrawler.git + +------------------------------------------------------------------- +About 'lib/javax.json-1.0.jar' +https://glassfish.java.net/public/CDDL+GPL_1_1.html diff --git a/src/talkCrawler.sh b/src/talkCrawler.sh new file mode 100644 index 0000000..aa0bce8 --- /dev/null +++ b/src/talkCrawler.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# +CLASSPATH=.:talkCrawler.jar +export CLASSPATH + +java -cp $CLASSPATH talkcrawler.DailyIndex $1 diff --git a/src/talkcrawler/DailyIndex.java b/src/talkcrawler/DailyIndex.java index fa49e6e..d482dc0 100644 --- a/src/talkcrawler/DailyIndex.java +++ b/src/talkcrawler/DailyIndex.java @@ -6,6 +6,7 @@ import java.net.HttpURLConnection; import java.net.URL; import java.text.DateFormat; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -24,18 +25,29 @@ /** * COMMAND + * 引数がない場合には、前日の月のクローリングを行う + * 年月が指定された場合には、指定の月のクローリングを行う * * @param args * @throws IOException + * @throws java.text.ParseException */ - public static void main(String[] args) throws IOException { + public static void main(String[] args) throws IOException, ParseException { Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - calendar.add(Calendar.DAY_OF_MONTH, -1); + if (args.length >= 1) { + DateFormat inputDate = new SimpleDateFormat("yyyy-MM"); + calendar.setTime(inputDate.parse(args[0])); + calendar.add(Calendar.MONTH, 1); + } + else { + calendar.setTime(new Date()); + calendar.add(Calendar.DAY_OF_MONTH, -1); + } DateFormat df = new SimpleDateFormat("yyyy-MMMMMMMM", Locale.UK); df.setTimeZone(TimeZone.getTimeZone("GMT")); String monthly = df.format(calendar.getTime()); + System.out.println("TalkCrawler "+ monthly); TalkCrawlerProperties prop = new TalkCrawlerProperties().load(); DailyIndex ins = new DailyIndex(prop, monthly, "date.html");