读书人

想用python写一个登录51job获取信息的

发布时间: 2013-01-07 10:02:24 作者: rapoo

想用python写一个登录51job获取信息的脚本
用chrome看了一下登录的过程,发现登录时的url为:
Request URL:http://my.51job.com/15089387965614251838/my/My_Pmc.php


我想问一下上面代码里的url参数15089387965614251838应该怎么获取?


我的代码:



myCookie = urllib2.HTTPCookieProcessor(cookielib.CookieJar());
opener = urllib2.build_opener(myCookie)

post_data = {
'username':'user',
'userpwd':'pwd',
'url':'',
'x':'45',
'y':'17'
}

#'http://my.51job.com/my/My_SignIn.php'
#url = 'http://my.51job.com/24101876372437709800/my/My_Pmc.php' #这个要输入验证码
url = 'http://my.51job.com/my/My_SignIn.php' #用这个url登录失败
req = urllib2.Request(url, urllib.urlencode(post_data))

html_src = opener.open(req).read()



[解决办法]
貌似可以直接使用
'http://my.51job.com/'

解析获取的页面中提交表单 <form action> 就可以得到
<form action="http://my.51job.com/39515986399789422305/my/My_Pmc.php" method="post" name="signin" id="signin" 

然后post内容

读书人网 >perl python

热点推荐