Python爬虫模拟登录(三):手动输入验证码,登录

拿到了参数password,还差一个验证码;

imgurl表示验证码图片地址;

接收图片并显示;

等待输入验证码后提交post;

    imgbuf = s.get(imgurl).content
    # print(len(imgbuf))
    # f = open('img/yzm.jpg', 'wb')
    # f.write(imgbuf)
    # f.close()

    f = BytesIO()
    f.write(imgbuf)

    img = Image.open(f)
    img.show()

    vercode = input("Verification Code:")
    postdata['yzm'] = vercode

    r = s.post(posturl, postdata)//提交post
    # print(r.text)
这样就算登录了。

猜你喜欢

转载自blog.csdn.net/M_N_N/article/details/80710767