Skip to content

Instantly share code, notes, and snippets.

@tvboxme
Forked from cj1324/vote.py
Created December 16, 2015 02:43
Show Gist options
  • Save tvboxme/7b95bcc4c7f6c46de67b to your computer and use it in GitHub Desktop.
Save tvboxme/7b95bcc4c7f6c46de67b to your computer and use it in GitHub Desktop.
lagou Vote for python2.x
#!/usr/bin/env python2
# encoding: utf-8
from __future__ import (unicode_literals,
print_function)
import time
import random
import urllib
import urllib2
import urlparse
from cookielib import CookieJar
HTTPTimeOut = 15
MainDomain = 'lagou.com'
RegDomain = 'passport.{0}'.format(MainDomain)
CaDomain = 'ca.{0}'.format(MainDomain)
RegPath = '/register/register.html'
RegGetArgs = 'ts=1449650316327&serviceId=topic&service=http%253A%252F%252Fca.lagou.com%252Fcareerism%252FbestEmployers%252Fnavigation%252Fteam.html%253FapplyType%253D41&action=register&signature=099DF8DB1E0703F8F5BB469E9D79268C'
PostPath = '/register/register.json'
GrantPath = '/grantServiceTicket/grant.html'
RegData = {'isValidate': True,
'email': '[email protected]',
'password': 'caf46f176d1fe981def81797e3aa195e',
'request_form_verifyCode': '',
'type': 1,
'protocol[]': 'agred'}
VotePath = '/careerism/bestEmployers/navigation/team.html?applyType=41'
PostVotePath = '/careerism/bestEmployers/vote/pc/vote.json'
PostData = {'id': 2847, 'applyType': 42}
def register(opener, pre):
opener.open('http://{0}{1}?{2}'.format(RegDomain, RegPath, RegGetArgs),
timeout=HTTPTimeOut)
curData = RegData.copy()
curData['email'] = pre + curData['email']
resp = opener.open('http://{0}{1}'.format(RegDomain, PostPath),
urllib.urlencode(curData),
timeout=HTTPTimeOut)
headers = resp.info()
print(resp.read())
resp = opener.open('http://{0}{1}'.format(RegDomain, GrantPath),
timeout=HTTPTimeOut)
headers = resp.info()
def vote(opener):
resp = opener.open('http://{0}{1}'.format(CaDomain, VotePath),
timeout=HTTPTimeOut)
headers = resp.info()
resp = opener.open('http://{0}{1}'.format(CaDomain, PostVotePath),
urllib.urlencode(PostData),
timeout=HTTPTimeOut)
headers = resp.info()
print(resp.read())
def once():
cj = CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
register(opener, 'demo' + unicode(random.randint(1000, 10000)))
vote(opener)
if __name__ == '__main__':
while True:
time.sleep(50)
once()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment