| @@ -0,0 +1,101 @@ | |||||
| import requests | |||||
| import time | |||||
| import ddddocr | |||||
| #import redis | |||||
| def get_baiyun(): | |||||
| session = requests.Session() | |||||
| captcha_url = "http://183.63.156.34:808/vems/login!secode.action?T=1745722152384" | |||||
| response = session.get(captcha_url) | |||||
| with open('captcha.jpg', 'wb') as f: | |||||
| f.write(response.content) | |||||
| #img_bytes = f.read() | |||||
| with open('captcha.jpg', 'rb') as f1: | |||||
| img_bytes = f1.read() | |||||
| ocr = ddddocr.DdddOcr() | |||||
| captcha_code = ocr.classification(img_bytes) | |||||
| print('captcha>>>>>'+captcha_code) | |||||
| login_url = "http://183.63.156.34:808/vems/login!doLogin.action" | |||||
| payload = {'username':'FWB','password':'SC123456','secode':captcha_code} | |||||
| headers = { | |||||
| 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7', | |||||
| 'Accept-Encoding': 'gzip, deflate', | |||||
| 'Accept-Language': 'zh-CN,zh;q=0.9', | |||||
| 'Connection': 'keep-alive', | |||||
| 'Content-Type':'application/x-www-form-urlencoded', | |||||
| 'Host': '183.63.156.34:808', | |||||
| 'Referer': 'http://183.63.156.34:808/vems/login.action', | |||||
| 'Upgrade-Insecure-Requests': '1', | |||||
| 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36', | |||||
| } | |||||
| response = session.post(login_url, headers=headers, data=payload) | |||||
| text = response.text | |||||
| #print(text) | |||||
| local_date_str = time.strftime("%Y-%m-%d", time.localtime()) | |||||
| print('locadatestr>>>>'+local_date_str) | |||||
| business_url = "http://183.63.156.34:808/vems/parkoperation/present-car!list.action?filter_I_parkingLotSeq=4&filter_I_licenseOrRandomCode=1&filter_S_carLicenseNumber=&filter_S_enterTimePeriod="+local_date_str+"+00%3A00%3A00+-+"+local_date_str+"+23%3A59%3A59&filter_I_recordType=&filter_I_isCorrect=&filter_I_confidence=100&filter_I_parkingTime=&filter_S_enterChannel=&filter_S_enterVipTypeAndName=&filter_I_openModel=&filter_S_openOperator=&filter_I_parkingAreaSeq=&filter_I_uploadYDT=&filter_S_flag=1&pageParam.pageNum=1&pageParam.pageSize=10" | |||||
| business_payload = {} | |||||
| business_headers = { | |||||
| #'Cookie': 'JSESSIONID=F5467599E1B0A528F7444C69909DAAB0', | |||||
| 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7', | |||||
| 'Accept-Encoding': 'gzip, deflate', | |||||
| 'Accept-Language': 'zh-CN,zh;q=0.9', | |||||
| 'Connection': 'keep-alive', | |||||
| 'Host': '183.63.156.34:808', | |||||
| 'Referer': 'http://183.63.156.34:808/vems/parkoperation/present-car!list.action?menuID=', | |||||
| 'Upgrade-Insecure-Requests': '1', | |||||
| 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36', | |||||
| } | |||||
| response = session.get(business_url, headers=business_headers, data=business_payload) | |||||
| text = response.text | |||||
| #print(text) | |||||
| key1= "<div class='table-pageNum col-sm-3'>" | |||||
| key1_len = len(key1) | |||||
| index1 = text.find(key1) | |||||
| key2 = '</div>' | |||||
| index2 = text[index1 + key1_len:].find(key2) | |||||
| cont = text[index1 + key1_len: index1 + key1_len + index2] | |||||
| print(cont) | |||||
| result = cont.split("总共")[1].replace("项","") | |||||
| print(result) | |||||
| with open('carCount.txt','w') as cf: | |||||
| cf.write(result) | |||||
| # pool = None | |||||
| # redisLink = None | |||||
| # try: | |||||
| # pool = redis.ConnectionPool(host='192.168.1.111', port=6379, decode_responses=True) | |||||
| # redisLink = redis.Redis(connection_pool=pool) | |||||
| # result = redisLink.set('key', '你好,欢迎来到Python3操作(Redis7.2.0)Redis应用') | |||||
| # print(result) # 打印结果:True 说明设置成功 | |||||
| # print("获取Key对应的值: ", redisLink.get('key')) | |||||
| # # ex: 设置过期时间(单位:秒) name为Key '老杨' 为value | |||||
| # #redisLink.set("name", "老杨", ex=3) | |||||
| # #time.sleep(1) | |||||
| # #resultValue = redisLink.get('name') | |||||
| # #print("请叫我:%s" % resultValue) | |||||
| # #time.sleep(3) | |||||
| # #print("3秒后请叫我无名小卒") | |||||
| # #print('name = %s' % (redisLink.get('name'))) | |||||
| # | |||||
| # except Exception as err: | |||||
| # print("redis连接异常: ", err) | |||||
| # finally: | |||||
| # print() | |||||
| # if redisLink is not None: | |||||
| # print("释放资源,连接还给连接池") | |||||
| # redisLink.close() | |||||
| # print(response.text) | |||||
| if __name__ == '__main__': | |||||
| while True: | |||||
| get_baiyun() | |||||
| time.sleep(60) | |||||