IT大国の、うそつきイニ
投稿者: pup_pooh_one 投稿日時: 2005/04/14 01:40 投稿番号: [46263 / 60270]
/**
* これやるから、早くソースを出せ!
* IT大国なんだからJavaくらいわかるだろ。
* 投稿すると、インデントがなくなるんだよなぁ〜
* 作成日: 2005/04/10
* @author pup_pooh_one
*/
import java.io.*;
import java.net.*;
public class Inishieni {
public static void main(String[] args) {
int messageNo = 0;
int words = args.length - 1;
String searchURL = "";
String nextURL = "";
String yahoo = "http://messages.yahoo.co.jp";
String nextMessage = "次のメッセージ ";
String message = "メッセージ: ";
System.out.println("Inishieni ver.0.2");
searchURL = args[0];
do {
String line = "";
int retry = 3;
try {
boolean isExist[] = new boolean[words];
for (int i = 0; i < words; i++) {
isExist[i] = false;
}
messageNo = 0;
URL url = new URL(searchURL);
BufferedReader reader = new BufferedReader(new InputStreamReader( url.openStream() ,"EUC-JP"));
while ((line = reader.readLine()) != null) {
int index = line.indexOf(message);
if (messageNo == 0 && index >= 0) {
messageNo = getMessageNo(line, index+message.length());
}
index = line.indexOf (nextMessage);
if (index >= 0) {
nextURL = getNextURL(line);
}
if (nextURL != "" && messageNo > 0 && line.indexOf ("掲示板検索: ") >= 0) {
break;
}
for (int j = 0; j < words; j++) {
if (line.indexOf (args[j+1]) >= 0) {
isExist[j] = true;
}
}
}
int count = 0;
for (int j = 0; j < words; j++) {
if (isExist[j] == true) {
count ++;
}
}
if (count == words) {
System.out.println("メッセージ:"+messageNo);
}
if (nextURL!="") {
searchURL = yahoo + nextURL;
}
}
catch (Exception e) {
if (retry == 0) break;
retry -- ;
System.out.println(searchURL);
System.out.println("エラー!! メッセージ:"+messageNo);
e.printStackTrace();
// break;
}
} while (nextURL != "");
System.out.println("done");
}
private static int getMessageNo(String line, int start) {
String result = "";
for (int i = start; i < line.length(); i++) {
if (line.charAt(i) == ' ') {
break;
}
result += line.charAt(i);
}
try {
return Integer.parseInt(result);
}
catch(NumberFormatException e)
{
return 0;
}
}
private static String getNextURL(String line) {
String nextURL = "";
boolean flag = false;
for (int i = 0; i < line.length(); i++) {
if (line.charAt(i) == '/') {
flag = true;
}
if (line.charAt(i) == '"' && line.charAt(i+1) == '>') {
break;
}
if (flag) {
nextURL += line.charAt(i);
}
}
return nextURL;
}
}
* これやるから、早くソースを出せ!
* IT大国なんだからJavaくらいわかるだろ。
* 投稿すると、インデントがなくなるんだよなぁ〜
* 作成日: 2005/04/10
* @author pup_pooh_one
*/
import java.io.*;
import java.net.*;
public class Inishieni {
public static void main(String[] args) {
int messageNo = 0;
int words = args.length - 1;
String searchURL = "";
String nextURL = "";
String yahoo = "http://messages.yahoo.co.jp";
String nextMessage = "次のメッセージ ";
String message = "メッセージ: ";
System.out.println("Inishieni ver.0.2");
searchURL = args[0];
do {
String line = "";
int retry = 3;
try {
boolean isExist[] = new boolean[words];
for (int i = 0; i < words; i++) {
isExist[i] = false;
}
messageNo = 0;
URL url = new URL(searchURL);
BufferedReader reader = new BufferedReader(new InputStreamReader( url.openStream() ,"EUC-JP"));
while ((line = reader.readLine()) != null) {
int index = line.indexOf(message);
if (messageNo == 0 && index >= 0) {
messageNo = getMessageNo(line, index+message.length());
}
index = line.indexOf (nextMessage);
if (index >= 0) {
nextURL = getNextURL(line);
}
if (nextURL != "" && messageNo > 0 && line.indexOf ("掲示板検索: ") >= 0) {
break;
}
for (int j = 0; j < words; j++) {
if (line.indexOf (args[j+1]) >= 0) {
isExist[j] = true;
}
}
}
int count = 0;
for (int j = 0; j < words; j++) {
if (isExist[j] == true) {
count ++;
}
}
if (count == words) {
System.out.println("メッセージ:"+messageNo);
}
if (nextURL!="") {
searchURL = yahoo + nextURL;
}
}
catch (Exception e) {
if (retry == 0) break;
retry -- ;
System.out.println(searchURL);
System.out.println("エラー!! メッセージ:"+messageNo);
e.printStackTrace();
// break;
}
} while (nextURL != "");
System.out.println("done");
}
private static int getMessageNo(String line, int start) {
String result = "";
for (int i = start; i < line.length(); i++) {
if (line.charAt(i) == ' ') {
break;
}
result += line.charAt(i);
}
try {
return Integer.parseInt(result);
}
catch(NumberFormatException e)
{
return 0;
}
}
private static String getNextURL(String line) {
String nextURL = "";
boolean flag = false;
for (int i = 0; i < line.length(); i++) {
if (line.charAt(i) == '/') {
flag = true;
}
if (line.charAt(i) == '"' && line.charAt(i+1) == '>') {
break;
}
if (flag) {
nextURL += line.charAt(i);
}
}
return nextURL;
}
}
これは メッセージ 46242 (inishieni さん)への返信です.