search

Home  >  Q&A  >  body text

python - 爬虫之模拟登入问题

在模拟登入极客学院时候,有个验证码,验证码链接后面带一个参数,琢磨不透这个参数怎么来的
类似这个验证码链接
http://passport.jikexueyuan.com/sso/verify?1459004256917
后面的一个参数1459004256917,这个是根据什么算出来的还是从哪里匹配下来的?

代码补充:

def startLogin(self):
        verify_img = r'http://passport.jikexueyuan.com/sso/verify?%s' %(time.time())
        print verify_img
        verify = raw_input('输入验证码:')
        login_data = {
            'expire':'7',
            'referer':'http://www.jikexueyuan.com/',
            'uname':self.username,
            'password':self.password,
            'verify':verify
        }
        s_login = login_session.post(self.loginurl,data=login_data,headers=headers)
        print type(s_login.json())
        for k,v in s_login.json().items():
            print k,v

最后执行的时候,得到的信息结果:

http://passport.jikexueyuan.com/sso/verify?1459164531.42
输入验证码:1857
<type 'dict'>
status 0
msg 验证码错误
jumpUrl /sso/login

老是提示验证码错误

PHP中文网PHP中文网2780 days ago724

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 17:30:00

    When submitting the URL, just use time.time() directly.

    import time
    url = 'http://passport.jikexueyuan.com/sso/verify?%s'%(time.time())

    reply
    0
  • 阿神

    阿神2017-04-17 17:30:00

    Time stamp only

    The number of milliseconds from now to 1970.1.1

    reply
    0
  • 迷茫

    迷茫2017-04-17 17:30:00

    Just write fixed, just to prevent caching.

    reply
    0
  • Cancelreply