Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Improve log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MaKraMc committed May 6, 2024
1 parent 8823879 commit 9fab1bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 1 addition & 6 deletions src/captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
import pytesseract

def solveCaptcha(captchaImage):
#[DEBUG]Save the captcha image
#with open("./captcha.png", "wb") as f:
# f.write(captchaImage)

# Solve the captcha
# First, convert the image to bytes
captchaImageBytes = Image.open(BytesIO(captchaImage))
# Then we can open the image with pytesseract ocr
captchaSolution = pytesseract.image_to_string(captchaImageBytes, config='--dpi 100').strip()
print(f"Got captcha: {captchaSolution}")


return captchaSolution
3 changes: 2 additions & 1 deletion src/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def login(driver, platform):
exit()

#Wait for the elements to load
print("Waiting for the whole webpage to load...", end='', flush=True)
print("Waiting for the login page...", end='', flush=True)

#Wait for the loading spinner to disappear
WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'div.van-toast.van-toast--loading[style*="display: none"]')))
Expand Down Expand Up @@ -90,6 +90,7 @@ def login(driver, platform):
captcha = solveCaptcha(PNGCaptchaImage)
i += 1

print(f"Got captcha: {captcha}")

#Paste the captcha
HTMLCaptcha = driver.find_element(By.CSS_SELECTOR, 'input[type="text"][name="vcode"]')
Expand Down

0 comments on commit 9fab1bc

Please sign in to comment.