fork download
  1. /// <summary>
  2. /// したらばの任意のスレに書き込みます。
  3. /// </summary>
  4. /// <param name="host">ホストアドレスを設定します。
  5. /// このプロパティはrefererにも使用されます。</param>
  6. /// <param name="bbs">板名</param>
  7. /// <param name="key">スレ番</param>
  8. public void WriteShitaraba(string dir, int bbs, int key, string name, string mail, string message)
  9. {
  10. bool writeCompleted = true;
  11.  
  12. try
  13. {
  14. string referer = String.Format("http://j...content-available-to-author-only...r.jp/bbs/read.cgi/{0}/{1}/{2}/", dir, bbs, key);
  15. 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);
  16. //string UploadStr = HttpUtility.UrlEncode(UploadStrOrig, Encoding.GetEncoding("Shift-JIS"));
  17. string UploadStr = new StringBuilder(Uri.EscapeDataString(UploadStrOrig)).ToString();
  18. byte[] UploadStrBytes = Encoding.GetEncoding("Shift-JIS").GetBytes(UploadStrOrig);
  19. Writer = (HttpWebRequest)HttpWebRequest.Create(String.Format("http://j...content-available-to-author-only...r.jp/bbs/write.cgi/{0}/{1}/{2}/", dir, bbs, key));
  20. Writer.Headers.Add("Origin:http://j...content-available-to-author-only...r.jp");
  21. Writer.Host = "jbbs.livedoor.jp";
  22. Writer.Accept = "*/*";
  23. Writer.Referer = referer;
  24. Writer.UserAgent = "Mozilla/5.0";
  25. Writer.KeepAlive = true;
  26. Writer.ContentLength = UploadStrBytes.Length;
  27. Writer.ContentType = "application/x-www-form-urlencoded";
  28. Writer.Method = "POST";
  29. WriterStream = Writer.GetRequestStream();
  30. WriterStream.Write(UploadStrBytes, 0, UploadStrBytes.Length);
  31. }
  32. catch (Exception)
  33. {
  34. MessageBox.Show("エラーが発生しました。やり直してください。");
  35. }
  36.  
  37. try
  38. {
  39. WriterResponse = (HttpWebResponse)Writer.GetResponse();
  40. }
  41. catch (Exception ex)
  42. {
  43. MessageBox.Show("書き込みに失敗\r\nエラーメッセージは次のとおり:\r\n{0}", ex.Message);
  44. writeCompleted = false;
  45. }
  46. finally
  47. {
  48. if (writeCompleted)
  49. MessageBox.Show("多分書き込んだはず");
  50. }
  51. }
  52.  
  53. private void buttonWrite_Click(object sender, EventArgs e)
  54. (
  55. try
  56. {
  57. Uri url = new Uri(toolStripTextBoxUrl.Text);
  58. }
  59. catch (UriFormatException)
  60. {
  61. return;
  62. }
  63. //http://j...content-available-to-author-only...r.jp/bbs/read.cgi/internet/14437/1336026627/
  64. System.Text.RegularExpressions.MatchCollection mc =
  65. System.Text.RegularExpressions.Regex.Matches(
  66. 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]+)/?$");
  67. foreach (System.Text.RegularExpressions.Match m in mc)
  68. {
  69. try
  70. {
  71. //正規表現を用いて頑張って探した文字列を元にレス(dat)を貰いに行ってもらう
  72. WriteShitaraba(m.Groups["dir"].Value, Convert.ToInt32(m.Groups["bbs"].Value), Convert.ToInt32(m.Groups["key"].Value), "名前", "メアドorさげ", "本文");
  73. }
  74. catch (FormatException)
  75. {
  76. MessageBox.Show("Urlが間違っているようです。正しいurlを入力してやり直してください。");
  77. return;
  78. }
  79. }
  80. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(8,21): error CS0116: A namespace can only contain types and namespace declarations
prog.cs(54,9): error CS8025: Parsing error
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty