clean up and improve this code in anyway you can: import requests from bs4 import…
- User
clean up and improve this code in anyway you can: import requests from bs4 import BeautifulSoup import re
import multiprocessing
session_guid: str search_secret: str
credentials = open('accounts.json',"r+")
procNum = input(int("number of processes:\n "))
login via username and password to ubox mobile, retrives sessionGUID which will be used to access POS for secret
def login(username, password): uboxMobile = "https://uboxmobile.uhaul.net/Launcher/" loginData = {"Smid": username, "Password": password, "EntityCode": ""} r = requests.post(url=uboxMobile, data=loginData, allow_redirects=True) ## fetch sessionGUID for urls in r.history: urls.headers = str(urls.headers) pattern = r"sessionGuid=([^&]+)" match = re.search(pattern, urls.headers) if match: session_guid = match.group(1) return session_guid else: return str(r.status_code) + f"\n{r.text}\n{str(r.status_code)}" ## catch anything else and display what it is try: soup = BeautifulSoup(r.content, "html.parser") results = soup.find('div', class_ = "validation-summary-errors") if results.text.strip() == "Invalid login.": return 'invalid login' except Exception: ## dogshit skiddery idc pass pool = multiprocessing.Pool(processes=procNum)
posGuid = pool.starmap(login, [(c["username"], c["password"]) for c in credentials]) # df010517:Dartmouth123
pool.close()
pool.join()
posGuid = login(a,b) in the future this will be able to take in creds from file if needed prob
pos login
params = {'app': 'CSFRewrite', 'guid': f'{posGuid}', 'entity': '10517', 'isDealer': 'True'} posUrl = "https://poslogin.uhaul.net/secure/LaunchToSite/Launch.aspx" r = requests.Session() ## start POS session
p = r.post(url=posUrl, params=params, allow_redirects=True)
lookupUrl = p.url.strip('/Index') + f"/Customer/SearchForCustomer" ## skiddery cleanup for url d = open('data.json') s = r.post(lookupUrl, data={'searchItem': [(d["id"]) for d in d]}) ## json format will be id: phoneNumber / Email print(s.text)
catch if invalid request
try: invalidUrl = "https://pos.uhaul.net/secure/CSFRewriteConsole3/Account/Timeout" ### login failure if r.url == invalidUrl: print("error reached the following URL: " + r.url) else: pass except Exception: pass
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.