試作品
投稿者: pup_pooh_one 投稿日時: 2005/04/10 02:45 投稿番号: [3681 / 15709]
/**イニの嘘検索プログラム
*/
import java.io.*;
import java.net.*;
public class Inishieni {
public static void main(String[] args) {
int messageNo = 0;
String nextURL = "";
String baseURL = "";
String yahoo = "http://messages.yahoo.co.jp";
String nextMessage = "次のメッセージ ";
String message = "メッセージ: ";
for (int i = 0; i < yahoo.length(); i++) {
baseURL += args[0].charAt(i);
}
System.out.println(baseURL);
nextURL = args[0];
while (nextURL != "") {
try {
URL url = new URL(nextURL);
BufferedReader reader = new BufferedReader(new InputStreamReader( url.openStream() ,"EUC-JP"));
String line;
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 (line.indexOf (args[1]) >= 0) {
System.out.println(messageNo);
System.out.println("メッセージ:"+messageNo);
break;
}
}
}
catch (Exception e) {
e.printStackTrace();
break;
}
if (messageNo == 0) {
nextURL = "";
}
if (nextURL!="") {
nextURL = baseURL + nextURL;
messageNo = 0;
}
}
}
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;
}
}
*/
import java.io.*;
import java.net.*;
public class Inishieni {
public static void main(String[] args) {
int messageNo = 0;
String nextURL = "";
String baseURL = "";
String yahoo = "http://messages.yahoo.co.jp";
String nextMessage = "次のメッセージ ";
String message = "メッセージ: ";
for (int i = 0; i < yahoo.length(); i++) {
baseURL += args[0].charAt(i);
}
System.out.println(baseURL);
nextURL = args[0];
while (nextURL != "") {
try {
URL url = new URL(nextURL);
BufferedReader reader = new BufferedReader(new InputStreamReader( url.openStream() ,"EUC-JP"));
String line;
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 (line.indexOf (args[1]) >= 0) {
System.out.println(messageNo);
System.out.println("メッセージ:"+messageNo);
break;
}
}
}
catch (Exception e) {
e.printStackTrace();
break;
}
if (messageNo == 0) {
nextURL = "";
}
if (nextURL!="") {
nextURL = baseURL + nextURL;
messageNo = 0;
}
}
}
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;
}
}
これは メッセージ 1 (guiseinoyuu さん)への返信です.
固定リンク:https://yarchive.emmanuelc.dix.asia/1835396/2pib9q2h5dfbaq0q0w2qa1a1kdcit_1/3681.html