Skip to content

Instantly share code, notes, and snippets.

@YoukouTenhouin
Last active December 20, 2015 20:29
Show Gist options
  • Save YoukouTenhouin/6190963 to your computer and use it in GitHub Desktop.
Save YoukouTenhouin/6190963 to your computer and use it in GitHub Desktop.
# coding:utf8
users_id = [600411795]
threads = 8
import os
import pickle
import requests
import threading
import traceback
from time import sleep
def get_tbs(session):
r = session.get('http://tieba.baidu.com/dc/common/tbs')
return r.json()['tbs']
try:
with open('vote_cookies','rb') as f:
users = pickle.load(f)
except:
exit(1)
def threadfunc(users):
s = requests.session()
post_data = {
'forum_id':101838,
'forum_name':'妹子',
'user_id':u,
'vote_type':'meizhi', #meizhi,weininang,renyao
}
url = 'http://tieba.baidu.com/encourage/post/meizhi/vote'
for i in users:
s.cookies = i[1]
while True:
try:
post_data['tbs'] = get_tbs(s)
r = s.post(url,data=post_data)
r = r.json()
print(u,i[0],r['no'],r['error'])
except KeyboardInterrupt:
exit(0)
except ValueError:
continue
except:
with open('vote_traceback','a') as f:
traceback.print_exc(file=f)
continue
else:
break
for u in users_id:
pid = os.fork()
if pid == 0:
continue
else:
for i in range(threads):
t = threading.Thread(target=threadfunc,args=(users[i::threads],))
t.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment