Skip to content

Instantly share code, notes, and snippets.

@scturtle
Created April 28, 2013 12:57
Show Gist options
  • Select an option

  • Save scturtle/5476820 to your computer and use it in GitHub Desktop.

Select an option

Save scturtle/5476820 to your computer and use it in GitHub Desktop.
vote for shanghaizoo
# coding: utf-8
#import httplib
#httplib.HTTPConnection.debuglevel = 1
import gevent
from gevent import monkey, Greenlet
monkey.patch_all()
from gevent.pool import Pool
import requests
import re
cnt = 0
url = 'http://www.shanghaizoo.cn/sites/shanghaizoo/VoteList.aspx'
headers = {'Content-Type':'application/x-www-form-urlencoded',
'Cookie':'ASP.NET_SessionId=3ocfn222bzrpbcrtyopx2q3y; CheckCode=1234',
'Referer':'http://www.shanghaizoo.cn/sites/shanghaizoo/VoteList.aspx'}
data='''__EVENTTARGET=VoteList1%24lbSubmit&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUIL\
Tc1NzA1MDlkZDYxHy7I5A9fIWh3saZI%2BmDCSSsf&__EVENTVALIDATION=%2FwEWBwLj%2F%2FY2AvKQ%\
2F94MAuT2kM0PAuDog8gFAvCc8KYNAtiHr6cHAtaHrOANLYHJUD8K4Sk0xJPs7DoLjE%2F7%2Bmk%3D&Vot\
eList1%24txtNickName=&VoteList1%24txtPhone=&VoteList1%24txtEmail=&VoteList1%24txtCh\
eckCode=1234&VoteList1%24txtSelectedVoteItem=b79e5dbc-9ec9-4dc5-84c9-8030a62b8a5f%7\
C'''
def vote():
global cnt
r = requests.post(url, data=data, headers=headers)
p = re.compile(r"alert\('([^']*)'\)")
cnt += 1
#print p.findall(r.text)[0].encode('utf-8')
print p.findall(r.text)[0].encode('gbk'), cnt
p = Pool(10)
def main():
while True:
p.spawn(vote)
Greenlet.spawn(main)
loop = gevent.core.loop()
loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment