Created
July 2, 2021 13:41
-
-
Save theArjun/4df575518db765beb81611968a96e697 to your computer and use it in GitHub Desktop.
Encrypt IMage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| API_URL = 'https://api.ocr.space/parse/image' | |
| API_KEY = '6c8f8b69c988957' | |
| image_content_class = 'captcha-image-dimension' | |
| IMAGE_URL = self.browser.find_element_by_class_name( | |
| image_content_class).get_attribute("src").replace('blob:', '') | |
| ic(IMAGE_URL) | |
| captcha_content = requests.get(IMAGE_URL, timeout=5).content | |
| image_64_encode = str(base64.encodestring(captcha_content)) | |
| ic(image_64_encode) | |
| request = requests.post(API_URL, | |
| data={ | |
| 'apikey': API_KEY, | |
| 'base64Image': image_64_encode, | |
| 'language': 'eng', | |
| }) | |
| ic(request.content) | |
| captcha = self.browser.find_element_by_xpath( | |
| "//input[@placeholder='Enter Captcha']") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment