找回密码
 注册

QQ登录

只需一步,快速开始

查看: 260|回复: 0

auto_poster

[复制链接]
发表于 2013-11-1 14:13:24 | 显示全部楼层 |阅读模式
auto_posterrefer to

  1. #!/bin/sh

  2. ############################################################
  3. #brief   A auto-poster used to post posts to a Discuz bbs
  4. #author  zeshengwu <wuzesheng86@gmail.com>
  5. #since   2011-03-04
  6. #version 1.0.0
  7. ############################################################

  8. if [ $# -ne 3 ]
  9. then
  10.         echo "usage: $0 board_id subject message"
  11.         exit 1
  12. fi

  13. #arguments
  14. g_fid=$1
  15. g_subject=`echo "$2" | iconv -fgb2312 -tutf8`
  16. g_message=`echo "$3" | iconv -fgb2312 -tutf8`

  17. #site info
  18. host=bbs.sosospider.com
  19. user=zeshengwu
  20. passwd=zeshengwu

  21. page=".page"
  22. header=".header"
  23. cookie_file=".cookie"
  24. user_agent="Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"

  25. #login discuz bbs
  26. function login()
  27. {
  28.         local url="http://$host/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&inajax=1"
  29.         local data="fastloginfield=username&username=$user&cookietime=2592000&password=$passwd&quickforward=yes&handlekey=ls&questionid=0&answer="
  30.         wget $url -d \
  31.               --save-cookies=$cookie_file \
  32.               --user-agent="$user_agent" \
  33.               --post-data="$data" \
  34.               -O $page \
  35.               -a $header 2>/dev/null
  36. }

  37. #get formhash from "$page"
  38. function get_formhash()
  39. {
  40.         formhash=`grep -Eio "formhash=.*" $page \
  41.                          | awk -F'"' '{print $1}' \
  42.                          | awk -F'=' '{print $2}'`
  43.         echo -n "$formhash"
  44. }

  45. #goto specified board
  46. function goto_board()
  47. {
  48.         local fid=$1
  49.         local url="http://$host/forum.php?mod=forumdisplay&fid=$fid"
  50.         wget $url -d \
  51.               --load-cookies=$cookie_file \
  52.               --user-agent="$user_agent" \
  53.               --save-cookies=$cookie_file \
  54.               -O $page \
  55.               -a $header 2>/dev/null
  56. }

  57. #post a new post
  58. function post()
  59. {
  60.         local fid=$1
  61.         local subject=$2
  62.         local message=$3

  63.         goto_board $fid
  64.         local formhash=`get_formhash`
  65.         local referer="http://$host/forum.php?mod=forumdisplay&fid=$fid"
  66.         local url="http://$host/forum.php?mod=post&action=newthread&fid=$fid&topicsubmit=yes&infloat=yes&handlekey=fastnewpost&inajax=1"
  67.         local data="subject=$subject&message=$message&formhash=$formhash&usesig=1"
  68.         wget $url -d \
  69.               --load-cookie=$cookie_file \
  70.               --user-agent="$user_agent" \
  71.               --referer="$referer" \
  72.               --post-data="$data" \
  73.               -O $page \
  74.               -a $header 2>/dev/null
  75. }

  76. #clear temporary files
  77. function clear()
  78. {
  79.         rm $page && rm $header && rm $cookie_file
  80. }

  81. login
  82. post $g_fid "$g_subject" "$g_message"
  83. clear
复制代码


您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-6-16 12:44 , Processed in 0.013290 second(s), 16 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表