私の学位論文の一部として、C でのプログラミングのコースの公式フォーラムをクロールし、返信を投稿するためによくある質問を検索する「ボット」を作成しました。適切な返信を投稿できるようにするには、ログインをシミュレートする必要があります。ログインフォームは以下の通りです。
!-- ログイン フォーム -- フォーム action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)"> script type="text/javascript" src=" clientscript/vbulletin_md5.js?v=385"> テーブル cellpadding="0" cellspacing="3" border="0"> tr> td class="smallfont" style="空白: nowrap;">Όνομα χρήστη td >
td class="smallfont" nowrap="nowrap">Αυτόματη Σύνδεση /tr> tr> td class="smallfont">Κωδικός td> td> /tr> /table>
input type="hidden" name="s" value="" /> input type="hidden" name="securitytoken" value="guest" /> input type="hidden" name="do" value="login " /> input type="hidden" name="vb_login_md5password" /> input type="hidden" name="vb_login_md5password_utf" /> /form> !-- / ログインフォーム -->
パスワードをmd5ハッシュする必要があることを理解しましたが、ログインできません。私は投稿方法を使用し、次のことを行ってコンテンツを準備します。
content = "do=login&url=login.php" + "&vb_login_md5password=" + md5_pass+ "&vb_login_md5password_utf="+ md5_pass + "&s=&securitytoken=guest&vb_login_username=" + UserName + "&vb_login_password=" + PassWprd;
次に、次のようにして競合を送信します。
urlConnection = (HttpURLConnection)(new URL(targetUrl).openConnection());
// Specifying that we intend to use this connection for input
urlConnection.setDoInput(true);
// Specifying that we intend to use this connection for output
urlConnection.setDoOutput(true);
// Specifying the method of HTTP request which is POST
// throws ProtocolException
urlConnection.setRequestMethod("POST");
// Specifying the content type of our post
urlConnection.setRequestProperty("Content-Type", POST_CONTENT_TYPE);
urlConnection.setRequestProperty("Content-length",String.valueOf (content.length()));
// urlConnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)");
// Prepare an output stream for writing data to the HTTP connection
// throws IOException
dataOutputStream = new DataOutputStream(urlConnection.getOutputStream());
dataOutputStream.writeBytes(content);
とはいえ、ログインできません。送信したフォームに何か問題があると思いますが、原因がわかりません。数日でプログラムを終了しなければならないので、助けていただければ幸いです。