Created
December 9, 2015 09:00
-
-
Save cj1324/d17988cdb8c663983884 to your computer and use it in GitHub Desktop.
lagou Vote for python2.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
哈哈。 你可以 fork 改改。 RegGetArgs
这里的值 也比较明显。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
email太明显,差评