python 模拟登陆51job企业中心,翻页取出所有简历

#!/usr/bin/python
#coding=utf8
import urllib
import urllib2
import cookielib
import base64
import re
import json
import hashlib
import rsa  
import binascii
import sys
import time


cj = cookielib.LWPCookieJar()
cookie_support = urllib2.HTTPCookieProcessor(cj)
opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler)
urllib2.install_opener(opener)

result = urllib2.urlopen("http://ehire.51job.com/MainLogin.aspx").read()
p = re.compile('<input type="hidden" name="hidAccessKey" id="hidAccessKey" value="(.*?)"')
hidAccessKey= p.search(result).group(1)
#print(hidAccessKey)
p = re.compile('<input type="hidden" name="fksc" id="fksc" value="(.*?)"')
fksc= p.search(result).group(1)
#print(fksc)
p = re.compile('<input type="hidden" name="hidEhireGuid" id="hidEhireGuid" value="(.*?)"')
hidEhireGuid= p.search(result).group(1)
#print(hidEhireGuid)

postdata = {
    'ctmName': 'xxxxxx',
    'userName': 'xxxxxx',
    'password':'xxxxx',
    'checkCode': '',
    'ec': hidEhireGuid,
    'isRememberMe': 'true',
    'langtype': 'Lang=&Flag=1',
    'oldAccessKey': hidAccessKey,   
    'returl':'',
    'sc':fksc
}

postdata = urllib.urlencode(postdata)
headers = {
    'User-Agent':'Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0',
    'Content-Type':    'application/x-www-form-urlencoded',
    'Referer':'http://ehire.51job.com/MainLogin.aspx',
    'Connection': 'keep-alive'
}
 
url='https://ehirelogin.51job.com/Member/UserLogin.aspx'

req = urllib2.Request(
    url = url,
        data = postdata,
        headers = headers
)
result = urllib2.urlopen(req)
#print(result.headers)
text = result.read()
#print(text);


你可能感兴趣的:(python 模拟登陆51job企业中心,翻页取出所有简历)