Skip to content

Instantly share code, notes, and snippets.

@cj1324
Created December 9, 2015 09:00
Show Gist options
  • Save cj1324/d17988cdb8c663983884 to your computer and use it in GitHub Desktop.
Save cj1324/d17988cdb8c663983884 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()
@tvboxme
Copy link

tvboxme commented Dec 9, 2015

email太明显,差评

domain_base = ['qq.com', '163.com', 'gmail.com', '126.com', 'vip.qq.com', 'sina.com', 'yahoo.com', 'baidu.com']
random_str = lambda base, max_length: ''.join(random.choice(base) for i in xrange(1+random.randrange(max_length)))
make_email = lambda : random_str(string.ascii_lowercase, 5) + random_str(string.digits, 10) + '@' + random.choice(domain_base)

@cj1324
Copy link
Author

cj1324 commented Dec 9, 2015

哈哈。 你可以 fork 改改。 RegGetArgs 这里的值 也比较明显。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment