#coding:utf-8 from farmbase import httpfetch import re import urllib import time import random if int(time.time())%40000>60: exit(1) exit(1) msg = [ '感谢分享', '支持楼主', '收藏', ] res = httpfetch(url='http://www.verycd.com/',needlogin=True) topics = re.compile(r'/topics/(\d+)').findall(res) topics = set(topics) print topics for topic in topics: url = 'http://www.verycd.com/topics/'+str(topic)+'/reply#fast-replay' print url postData = { 'contents':random.choice(msg), 'use_bbcode':'1', 'tid':str(topic), 'Action':'FolderCommentOperate:doReplyFolder' } postData = urllib.urlencode(postData) kk = httpfetch(url=url,needlogin=True,postData=postData) time.sleep(5) for i in range(20): postData = { 'title':'Level_up_everyday_'+str(i), 'contents':'haha', 'tags':'', 'use_bbcode':'1', 'Action':'Post:doNewTopic', 'tid':'', 'gurl':'@g2385413', 'pid':'', 'qpid':'', 'continueURI':'' } postData = urllib.urlencode(postData) url = 'http://www.verycd.com/groups/@g2385413/topics/new' print url kk = httpfetch(url=url,needlogin=True,postData=postData) time.sleep(5) for i in range(3,4): res = httpfetch(url='http://www.verycd.com/groups/@g2385413/page'+str(i),needlogin=True,postData=None) topics = re.compile(r'').findall(res) print topics for topic in topics: tid = re.compile(r'(\d+)\.topic').findall(topic)[0] print tid postData = { 'contents':'upupup,spspsp,:):):)', 'use_bbcode':'1', 'tid':tid, 'showall':'', 'Action':'Post:doReply' } postData = urllib.urlencode(postData) url='http://www.verycd.com'+topic+'/reply' print url kk = httpfetch(url=url,needlogin=True,postData=postData) time.sleep(5)