#!/usr/bin/python
# -*- coding:utf-8 -*-
# Author: LiTianle
# Time:2019/9/24 15:36
'''
<h3>你需要在网址后输入数字53639</h3>
<h3>下一个你需要输入的数字是10963. </h3>
'''
import requests,re
def main():
    url='http://www.heibanke.com/lesson/crawler_ex01/'
    headers={
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
    }
    data={'username':'litianle','password':1}
    ex='<h3>(.*)</h3>'
    for i in range(30):
        respone_page=requests.post(url=url,data={'username':'litianle','password':i}).text
        result=re.findall(ex,respone_page,re.S)[0]
        print(result,i)
        if '成功' in result:
            nex_url=re.findall('<a href="(.*)/"',respone_page,re.S)[0]
            print('下一关:'+'http://www.heibanke.com'+nex_url)
            break

if __name__ == '__main__':
    main()