python 黑板课爬虫闯关-第二关

 

#!/usr/bin/python
# -*- coding:utf-8 -*-
# Author: LiTianle
# Time:2019/9/24 15:36
'''

你需要在网址后输入数字53639

下一个你需要输入的数字是10963.

''' 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='

(.*)

' 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('',respone_page,re.S)[0] print('下一关:'+'http://www.heibanke.com'+nex_url) break if __name__ == '__main__': main()

 

你可能感兴趣的:(python 黑板课爬虫闯关-第二关)