/// <summary>
/// したらばの任意のスレに書き込みます。
/// </summary>
/// <param name="host">ホストアドレスを設定します。
/// このプロパティはrefererにも使用されます。</param>
/// <param name="bbs">板名</param>
/// <param name="key">スレ番</param>
public void WriteShitaraba(string dir, int bbs, int key, string name, string mail, string message)
{
bool writeCompleted = true;
try
{
string referer = String.Format("http://j...content-available-to-author-only...r.jp/bbs/read.cgi/{0}/{1}/{2}/", dir, bbs, key);
string UploadStrOrig = String.Format("DIR={0}&BBS={1}&TIME={2}&NAME={3}&MAIL={4}&MESSAGE={5}&KEY={6}&submit=書き込む", dir, bbs, getNowUnixTime(), name, mail, message, key);
//string UploadStr = HttpUtility.UrlEncode(UploadStrOrig, Encoding.GetEncoding("Shift-JIS"));
string UploadStr = new StringBuilder(Uri.EscapeDataString(UploadStrOrig)).ToString();
byte[] UploadStrBytes = Encoding.GetEncoding("Shift-JIS").GetBytes(UploadStrOrig);
Writer = (HttpWebRequest)HttpWebRequest.Create(String.Format("http://j...content-available-to-author-only...r.jp/bbs/write.cgi/{0}/{1}/{2}/", dir, bbs, key));
Writer.Headers.Add("Origin:http://j...content-available-to-author-only...r.jp");
Writer.Host = "jbbs.livedoor.jp";
Writer.Accept = "*/*";
Writer.Referer = referer;
Writer.UserAgent = "Mozilla/5.0";
Writer.KeepAlive = true;
Writer.ContentLength = UploadStrBytes.Length;
Writer.ContentType = "application/x-www-form-urlencoded";
Writer.Method = "POST";
WriterStream = Writer.GetRequestStream();
WriterStream.Write(UploadStrBytes, 0, UploadStrBytes.Length);
}
catch (Exception)
{
MessageBox.Show("エラーが発生しました。やり直してください。");
}
try
{
WriterResponse = (HttpWebResponse)Writer.GetResponse();
}
catch (Exception ex)
{
MessageBox.Show("書き込みに失敗\r\nエラーメッセージは次のとおり:\r\n{0}", ex.Message);
writeCompleted = false;
}
finally
{
if (writeCompleted)
MessageBox.Show("多分書き込んだはず");
}
}
private void buttonWrite_Click(object sender, EventArgs e)
(
try
{
Uri url = new Uri(toolStripTextBoxUrl.Text);
}
catch (UriFormatException)
{
return;
}
//http://j...content-available-to-author-only...r.jp/bbs/read.cgi/internet/14437/1336026627/
System.Text.RegularExpressions.MatchCollection mc =
System.Text.RegularExpressions.Regex.Matches(
toolStripTextBoxUrl.Text, @"http://j...content-available-to-author-only...r.jp/bbs/read.cgi/(?<dir>[a-zA-Z0-9]+)/(?<bbs>[0-9]+)/(?<key>[0-9]+)/?$");
foreach (System.Text.RegularExpressions.Match m in mc)
{
try
{
//正規表現を用いて頑張って探した文字列を元にレス(dat)を貰いに行ってもらう
WriteShitaraba(m.Groups["dir"].Value, Convert.ToInt32(m.Groups["bbs"].Value), Convert.ToInt32(m.Groups["key"].Value), "名前", "メアドorさげ", "本文");
}
catch (FormatException)
{
MessageBox.Show("Urlが間違っているようです。正しいurlを入力してやり直してください。");
return;
}
}
}
ICAgICAgICAvLy8gPHN1bW1hcnk+CiAgICAgICAgLy8vIOOBl+OBn+OCieOBsOOBruS7u+aEj+OBruOCueODrOOBq+abuOOBjei+vOOBv+OBvuOBmeOAggogICAgICAgIC8vLyA8L3N1bW1hcnk+CiAgICAgICAgLy8vIDxwYXJhbSBuYW1lPSJob3N0Ij7jg5vjgrnjg4jjgqLjg4njg6zjgrnjgpLoqK3lrprjgZfjgb7jgZnjgIIKICAgICAgICAvLy8g44GT44Gu44OX44Ot44OR44OG44Kj44GvcmVmZXJlcuOBq+OCguS9v+eUqOOBleOCjOOBvuOBmeOAgjwvcGFyYW0+CiAgICAgICAgLy8vIDxwYXJhbSBuYW1lPSJiYnMiPuadv+WQjTwvcGFyYW0+CiAgICAgICAgLy8vIDxwYXJhbSBuYW1lPSJrZXkiPuOCueODrOeVqjwvcGFyYW0+CiAgICAgICAgcHVibGljIHZvaWQgV3JpdGVTaGl0YXJhYmEoc3RyaW5nIGRpciwgaW50IGJicywgaW50IGtleSwgc3RyaW5nIG5hbWUsIHN0cmluZyBtYWlsLCBzdHJpbmcgbWVzc2FnZSkKICAgICAgICB7CiAgICAgICAgICAgIGJv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uanAvYmJzL3dyaXRlLmNnaS97MH0vezF9L3syfS8iLCBkaXIsIGJicywga2V5KSk7CiAgICAgICAgICAgICAgICBXcml0ZXIuSGVhZGVycy5BZGQoIk9yaWdpbjpodHRwOi8vai4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4uci5qcCIpOwogICAgICAgICAgICAgICAgV3JpdGVyLkhvc3QgPSAiamJicy5saXZlZG9vci5qcCI7CiAgICAgICAgICAgICAgICBXcml0ZXIuQWNjZXB0ID0gIiovKiI7CiAgICAgICAgICAgICAgICBXcml0ZXIuUmVmZXJlciA9IHJlZmVyZXI7CiAgICAgICAgICAgICAgICBXcml0ZXIuVXNlckFnZW50ID0gIk1vemlsbGEvNS4wIjsKICAgICAgICAgICAgICAgIFdyaXRlci5LZWVwQWxpdmUgPSB0cnVlOwogICAgICAgICAgICAgICAgV3JpdGVyLkNvbnRlbnRMZW5ndGggPSBVcGxvYWRTdHJCeXRlcy5MZW5ndGg7CiAgICAgICAgICAgICAgICBXcml0ZXIuQ29udGVudFR5cGUgPSAiYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkIjsKICAgICAgICAgICAgICAgIFdyaXRlci5NZXRob2QgPSAiUE9TVCI7CiAgICAgICAgICAgICAgICBXcml0ZXJTdHJlYW0gPSBXcml0ZXIuR2V0UmVxdWVzdFN0cmVhbSgpOwogICAgICAgICAgICAgICAgV3JpdGVyU3RyZWFtLldyaXRlKFVwbG9hZFN0ckJ5dGVzLCAwLCBVcGxvYWRTdHJCeXRlcy5MZW5ndGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNhdGNoIChFeGNlcHRpb24pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIE1lc3NhZ2VCb3guU2hvdygi44Ko44Op44O844GM55m655Sf44GX44G+44GX44Gf44CC44KE44KK55u044GX44Gm44GP44Gg44GV44GE44CCIik7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHRyeQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBXcml0ZXJSZXNwb25zZSA9IChIdHRwV2ViUmVzcG9uc2UpV3JpdGVyLkdldFJlc3BvbnNlKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY2F0Y2ggKEV4Y2VwdGlvbiBleCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgTWVzc2FnZUJveC5TaG93KCLmm7jjgY3ovrzjgb/jgavlpLHmlZdcclxu44Ko44Op44O844Oh44OD44K744O844K444Gv5qyh44Gu44Go44GK44KKOlxyXG57MH0iLCBleC5NZXNzYWdlKTsKICAgICAgICAgICAgICAgIHdyaXRlQ29tcGxldGVkID0gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZmluYWxseQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAod3JpdGVDb21wbGV0ZWQpCiAgICAgICAgICAgICAgICAgICAgTWVzc2FnZUJveC5TaG93KCLlpJrliIbmm7jjgY3ovrzjgpPjgaDjga/jgZoiKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAKICAgICAgICBwcml2YXRlIHZvaWQgYnV0dG9uV3JpdGVfQ2xpY2sob2JqZWN0IHNlbmRlciwgRXZlbnRBcmdzIGUpCiAgICAgICAgKAogICAgICAgICAgICB0cnkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgVXJpIHVybCA9IG5ldyBVcmkodG9vbFN0cmlwVGV4dEJveFVybC5UZXh0KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjYXRjaCAoVXJpRm9ybWF0RXhjZXB0aW9uKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy9odHRwOi8vai4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4uci5qcC9iYnMvcmVhZC5jZ2kvaW50ZXJuZXQvMTQ0MzcvMTMzNjAyNjYyNy8KICAgICAgICAgICAgU3lzdGVtLlRleHQuUmVndWxhckV4cHJlc3Npb25zLk1hdGNoQ29sbGVjdGlvbiBtYyA9CiAgICAgICAgICAgICAgICBTeXN0ZW0uVGV4dC5SZWd1bGFyRXhwcmVzc2lvbnMuUmVnZXguTWF0Y2hlcygKICAgICAgICAgICAgICAgIHRvb2xTdHJpcFRleHRCb3hVcmwuVGV4dCwgQCJodHRwOi8vai4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4uci5qcC9iYnMvcmVhZC5jZ2kvKD88ZGlyPlthLXpBLVowLTldKykvKD88YmJzPlswLTldKykvKD88a2V5PlswLTldKykvPyQiKTsKICAgICAgICAgICAgZm9yZWFjaCAoU3lzdGVtLlRleHQuUmVndWxhckV4cHJlc3Npb25zLk1hdGNoIG0gaW4gbWMpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHRyeQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIC8v5q2j6KaP6KGo54++44KS55So44GE44Gm6aCR5by144Gj44Gm5o6i44GX44Gf5paH5a2X5YiX44KS5YWD44Gr44Os44K5KGRhdCnjgpLosrDjgYTjgavooYzjgaPjgabjgoLjgonjgYYKICAgICAgICAgICAgICAgICAgICBXcml0ZVNoaXRhcmFiYShtLkdyb3Vwc1siZGlyIl0uVmFsdWUsIENvbnZlcnQuVG9JbnQzMihtLkdyb3Vwc1siYmJzIl0uVmFsdWUpLCBDb252ZXJ0LlRvSW50MzIobS5Hcm91cHNbImtleSJdLlZhbHVlKSwgIuWQjeWJjSIsICLjg6HjgqLjg4lvcuOBleOBkiIsICLmnKzmlociKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNhdGNoIChGb3JtYXRFeGNlcHRpb24pCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgTWVzc2FnZUJveC5TaG93KCJVcmzjgYzplpPpgZXjgaPjgabjgYTjgovjgojjgYbjgafjgZnjgILmraPjgZfjgYR1cmzjgpLlhaXlipvjgZfjgabjgoTjgornm7TjgZfjgabjgY/jgaDjgZXjgYTjgIIiKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9