Skip to content

Instantly share code, notes, and snippets.

@theArjun
Created July 2, 2021 13:41
Show Gist options
  • Select an option

  • Save theArjun/4df575518db765beb81611968a96e697 to your computer and use it in GitHub Desktop.

Select an option

Save theArjun/4df575518db765beb81611968a96e697 to your computer and use it in GitHub Desktop.
Encrypt IMage
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