import bs4 import requests from PIL import Image from io import BytesIO import json url = [' http://urp.hebau.edu.cn:9001','http://urp.hebau.edu.cn:9002', 'http://urp.hebau.edu.cn:9003','http://urp.hebau.edu.cn:9004', 'http://urp.hebau.edu.cn:9005','http://urp.hebau.edu.cn/'] session = requests.session() header = {} def Yzm(i): global header header={ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Host': url[i].split("//")[1], 'Origin': 'http://urp.hebau.edu.cn:9003', 'Referer': 'http://urp.hebau.edu.cn:9003/loginAction.do', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36' } return session.get(url=url[i] + '/loginAction.do',headers=header) a = 2 YZM_URL = Yzm(a) cookie = YZM_URL.headers['Set-Cookie'] cookie = cookie.strip('; path=/') yzm_url = 'http://urp.hebau.edu.cn:9003/validateCodeAction.do?random=' YZM_Header = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'Host': url[0].split("//")[1], 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Connection': 'keep-alive', 'Origin': 'http://urp.hebau.edu.cn:9003', 'Referer': 'http://urp.hebau.edu.cn:9003/loginAction.do', 'cookie': cookie, 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36' } #print(YZM_URL.text) yzmdata = session.get(yzm_url,headers=YZM_Header) tempIm = BytesIO(yzmdata.content) im = Image.open(tempIm) im.show() yzm = input("请输入验证码:") usename = input("请输入账号:") password = input("请输入账号:") postdata = { "zjh":usename, "mm":password, 'v_yzm':yzm } header['cookie'] =cookie login = session.post(url=url[a] + '/loginAction.do',data=postdata,headers=header) #print(login.text) KCB_header=YZM_Header KCB_header['Referer'] += '/menu/menu.jsp ' print(KCB_header) CSC_url = url[a] + '/xkAction.do?actionType=6' CSC = session.get(url=CSC_url,headers=KCB_header) print(CSC.text) Kb = bs4.BeautifulSoup(CSC.text,'lxml') with open("laopo.txt",'w',encoding='utf-8') as f: f.write(CSC.text)
神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试