メインコンテンツまでスキップ

「Bot」タグの記事が2件件あります

全てのタグを見る

JavaプログラムからExcite翻訳を利用

· 約3分
Yu Sasaki
Enterprise Security Manager / Advisor

POSTメソッドを用いてWebページのフォームにリクエストを送信し、そのレスポンスを取得するプログラム例として、エキサイト 翻訳を利用してみます。 送信クエリの1つは翻訳言語設定、2つ目は翻訳対象文字列でレスポンスのWebページから翻訳された文字列を抽出します。

ソースコード

import java.net.*;
import java.util.regex.*;
import java.io.*;
/**
* Excite翻訳(http://www.excite.co.jp/world/)を利用するクラス
*/
public class ExciteTrans {
private String direction; // 翻訳する言語設定 "ENJA" or "JAEN"
/** テスト用main() */
public static void main(String[] args) {
ExciteTrans et = new ExciteTrans();
System.out.println(et.getTransText("Hello!")); // 翻訳対象テキスト
}
/** コンストラクタ */
public ExciteTrans() { direction ="ENJA"; }
public ExciteTrans(String str) {
if (str.equals("JAEN") || str.equals("ENJA"))
direction = str;
else
direction ="JAEN";
}
/**
* テキストを翻訳
* @param before 翻訳前のテキスト
* @return 翻訳後のテキスト
*/
public String getTransText(String before) {
String afterText = null; // 翻訳されたテキスト
try {
// URLクラスのインスタンスを生成
URL exciteURL =
new URL("http://www.excite.co.jp/world/english/");
// 接続します
URLConnection con = exciteURL.openConnection();
// 出力を行うように設定
con.setDoOutput(true);
// 出力ストリームを取得
PrintWriter out = new PrintWriter(con.getOutputStream());
// クエリー文の生成・送信
out.print("before={"+ before +"}&wb_lp={"+ direction +"}");
out.close();
// 入力ストリームを取得
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
// 一行ずつ読み込む
String aline;
// 抽出用の正規表現
String regex = "<textarea [^>].*after.*>(.*)";
Pattern pattern = Pattern.compile(regex);
while ((aline = in.readLine()) != null) {
Matcher mc = pattern.matcher(aline);
if(mc.matches()) {
afterText = mc.group(1);
}
}
in.close(); // 入力ストリームを閉じる
} catch (IOException e) {
e.printStackTrace();
}
return afterText;
}
}

実行結果

こんにちは!

Java MSN Messenger Library (JML)で翻訳ロボを作る

Java MSN Messenger Library (JML)とは Windows Live Messenger 上の通信プロトコルMSNP8-MSNP12をサポートするライブラリです。主に、メンバーの会話に自動応答するチャットボット(Chat Bot)や人工無脳などを作る際に用いられます。 今回は、ライブラリに付属しているサンプルプログラムのEchoMessengerクラスにこの翻訳クラスをかませて、メンバーの発言を翻訳し、その文字列色をランダムで選択した色で応答するチャットボットを作成してみました。 実行結果は下図になります。 ![JML翻訳ロボの実行結果例](./naiTrans-e1273383658134.png) コンストラクタでの翻訳言語設定が逆でも、文字列が英語or日本語に統一されていれば、Excite翻訳側がそれに合わせて適当な言語で翻訳するみたいです。 最後に、

礼儀正しくクローリングする際は

  • robots.txtやメタタグを守るように
  • 相手サーバに負荷をかけすぎないように
  • 相手Webサイトポリシー(利用規約)を守るように
  • 頻繁に使いたいモノなら、同機能のWebサービスを使うこと(利用規約内で)
うーん、今回のようなプログラムの利用はあまりよくないようでね。

RMT, the Eye of the Storm in the Net Game

· 約3分
Yu Sasaki
Enterprise Security Manager / Advisor

Recently, the online game has been more popular together with developing the computer's performance and building the network.
At the same time, some people pick out not only the real value but also virtual one.

In online game, some player buy the game currency for the real one.
That is RMT standing for Real Money Trading.

They often buy through the agent.
The employee of the brokerage firm describes that the main users are busy salaried workers who wanna enjoy the game with not having much time.
That firm takes up the game currency from the heavy user who spend much time in a day.
He said that I earn fifteen thousand yen per a month. In addition, he also assert that the demand of the game currency will increase.

But the company of making online game doesn't formally admit RMT.
One of reasons stem from the bot. Well, I'll try to state the present problem of RMT including the bot.

A bot is defined as the computer program that operate to earn the game currency automatically and unfairly in online game as the game character.
A bot comes from a robot. For instance, the bot character on the game searches the enemy, smashes it, and gets the game money. it repeats the cycle without a break.

But the bot pressure burden towards the game server and disturb the human player enjoying it. For that reason, the company bans the bot and detects bots with the manpower around the clock.

Since the pattern of the bot movement is regular and fixed, the stuff can detect easily. Nevertheless, the innumerable bot annoy the game company.

The user of the bot access the online game from China mostly.
Some users remark that we gain by the reminder of currency rat between China and Japan and between the real and the game.
Some online game company prohibit the bot user from accessing the game from China. But they attempt to access it through the relay server in Japan.

While some Japanese game company are puzzled over RMT's problem, the
American game company that has spread and argued with online game market perform the business that premise RMT. "Second Life" is a case in point.

I deduce that on the Net it's difficult for authority to grasp the distribution route and amount but according to making them visual as the business, we can conceive the new way of sound enjoying the game.

Frankly speaking, I think the virtual world encroaches the real one whether or not.