-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding methods mtcaptcha, friendly captcha, cutcaptcha (#73)
* Adding methods mtcaptcha, friendly captcha, cutcaptcha to solver.py Adding examples mtchaptcha.py, mtcaptcha_options.py, friendly_captcha.py, friendly_captcha_options.py, cutcaptcha.py, cutcaptcha_options.py to examples folder Adding tests test_mtcaptcha.py, test_friendly_captcha.py, test_cutcaptcha.py to tests folder Signed-off-by: Maxim S <[email protected]> * - Fixed parameter {'method': 'cutcaptcha'} in the "send" parameters of the send request in the file test_cutcaptcha.py - Adding .idea/, .DS_Store to .gitignore Signed-off-by: Maxim S <[email protected]> --------- Signed-off-by: Maxim S <[email protected]>
- Loading branch information
Showing
12 changed files
with
391 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,4 +137,6 @@ dmypy.json | |
# Cython debug symbols | ||
cython_debug/ | ||
|
||
.vscode/ | ||
.vscode/ | ||
.idea/ | ||
.DS_Store |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import sys | ||
import os | ||
|
||
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) | ||
|
||
from twocaptcha import TwoCaptcha | ||
|
||
# in this example we store the API key inside environment variables that can be set like: | ||
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS | ||
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows | ||
# you can just set the API key directly to it's value like: | ||
# api_key="1abc234de56fab7c89012d34e56fa7b8" | ||
|
||
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY') | ||
|
||
|
||
solver = TwoCaptcha(api_key) | ||
|
||
try: | ||
result = solver.cutcaptcha( | ||
misery_key='ad52c87af17e2ec09b8d918c9f00416b1cb8c320', | ||
apikey='SAs61IAI', | ||
url='https://mysite.com/page/with/cutcaptcha', | ||
) | ||
|
||
except Exception as e: | ||
sys.exit(e) | ||
|
||
else: | ||
sys.exit('result: ' + str(result)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import sys | ||
import os | ||
|
||
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) | ||
|
||
from twocaptcha import TwoCaptcha | ||
|
||
# in this example we store the API key inside environment variables that can be set like: | ||
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS | ||
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows | ||
# you can just set the API key directly to it's value like: | ||
# api_key="1abc234de56fab7c89012d34e56fa7b8" | ||
|
||
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY') | ||
|
||
config = { | ||
'server': '2captcha.com', # can be also set to 'rucaptcha.com' | ||
'apiKey': api_key, | ||
'softId': 123, | ||
# 'callback': 'https://your.site/result-receiver', # if set, sovler with just return captchaId, not polling API for the answer | ||
'defaultTimeout': 120, | ||
'recaptchaTimeout': 600, | ||
'pollingInterval': 10, | ||
} | ||
|
||
solver = TwoCaptcha(**config) | ||
|
||
try: | ||
result = solver.cutcaptcha(misery_key='ad52c87af17e2ec09b8d918c9f00416b1cb8c320', | ||
apikey='SAs61IAI', | ||
url='https://mysite.com/page/with/cutcaptcha' | ||
# proxy={ | ||
# 'type': 'HTTPS', | ||
# 'uri': 'login:password@IP_address:PORT' | ||
# } | ||
) | ||
|
||
except Exception as e: | ||
sys.exit(e) | ||
|
||
else: | ||
sys.exit('result: ' + str(result)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import sys | ||
import os | ||
|
||
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) | ||
|
||
from twocaptcha import TwoCaptcha | ||
|
||
# in this example we store the API key inside environment variables that can be set like: | ||
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS | ||
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows | ||
# you can just set the API key directly to it's value like: | ||
# api_key="1abc234de56fab7c89012d34e56fa7b8" | ||
|
||
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY') | ||
|
||
solver = TwoCaptcha(api_key) | ||
|
||
try: | ||
result = solver.friendly_captcha( | ||
sitekey='FCMGEMUD2KTDSQ5H', | ||
url='https://friendlycaptcha.com/demo', | ||
) | ||
|
||
except Exception as e: | ||
sys.exit(e) | ||
|
||
else: | ||
sys.exit('result: ' + str(result)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import sys | ||
import os | ||
|
||
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) | ||
|
||
from twocaptcha import TwoCaptcha | ||
|
||
# in this example we store the API key inside environment variables that can be set like: | ||
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS | ||
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows | ||
# you can just set the API key directly to it's value like: | ||
# api_key="1abc234de56fab7c89012d34e56fa7b8" | ||
|
||
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY') | ||
|
||
config = { | ||
'server': '2captcha.com', # can be also set to 'rucaptcha.com' | ||
'apiKey': api_key, | ||
'softId': 123, | ||
# 'callback': 'https://your.site/result-receiver', # if set, sovler with just return captchaId, not polling API for the answer | ||
'defaultTimeout': 120, | ||
'recaptchaTimeout': 600, | ||
'pollingInterval': 10, | ||
} | ||
|
||
solver = TwoCaptcha(**config) | ||
|
||
try: | ||
result = solver.friendly_captcha(sitekey='FCMGEMUD2KTDSQ5H', | ||
url='https://friendlycaptcha.com/demo', | ||
# proxy={ | ||
# 'type': 'HTTPS', | ||
# 'uri': 'login:password@IP_address:PORT' | ||
# } | ||
) | ||
|
||
except Exception as e: | ||
sys.exit(e) | ||
|
||
else: | ||
sys.exit('result: ' + str(result)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import sys | ||
import os | ||
|
||
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) | ||
|
||
from twocaptcha import TwoCaptcha | ||
|
||
# in this example we store the API key inside environment variables that can be set like: | ||
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS | ||
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows | ||
# you can just set the API key directly to it's value like: | ||
# api_key="1abc234de56fab7c89012d34e56fa7b8" | ||
|
||
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY') | ||
|
||
solver = TwoCaptcha(api_key) | ||
|
||
try: | ||
result = solver.mtcaptcha( | ||
sitekey='MTPublic-KzqLY1cKH', | ||
url='https://2captcha.com/demo/mtcaptcha', | ||
) | ||
|
||
except Exception as e: | ||
sys.exit(e) | ||
|
||
else: | ||
sys.exit('result: ' + str(result)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import sys | ||
import os | ||
|
||
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) | ||
|
||
from twocaptcha import TwoCaptcha | ||
|
||
# in this example we store the API key inside environment variables that can be set like: | ||
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS | ||
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows | ||
# you can just set the API key directly to it's value like: | ||
# api_key="1abc234de56fab7c89012d34e56fa7b8" | ||
|
||
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY') | ||
|
||
config = { | ||
'server': '2captcha.com', # can be also set to 'rucaptcha.com' | ||
'apiKey': api_key, | ||
'softId': 123, | ||
# 'callback': 'https://your.site/result-receiver', # if set, sovler with just return captchaId, not polling API for the answer | ||
'defaultTimeout': 120, | ||
'recaptchaTimeout': 600, | ||
'pollingInterval': 10, | ||
} | ||
|
||
solver = TwoCaptcha(**config) | ||
|
||
try: | ||
result = solver.mtcaptcha(sitekey='MTPublic-KzqLY1cKH', | ||
url='https://2captcha.com/demo/mtcaptcha', | ||
# proxy={ | ||
# 'type': 'HTTPS', | ||
# 'uri': 'login:password@IP_address:PORT' | ||
# } | ||
) | ||
|
||
except Exception as e: | ||
sys.exit(e) | ||
|
||
else: | ||
sys.exit('result: ' + str(result)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import unittest | ||
|
||
try: | ||
from .abstract import AbstractTest | ||
except ImportError: | ||
from abstract import AbstractTest | ||
|
||
|
||
class CutcaptchaTest(AbstractTest): | ||
|
||
def test_all_params(self): | ||
params = { | ||
'misery_key': 'ad52c87af17e2ec09b8d918c9f00416b1cb8c320', | ||
'apikey': 'SAs61IAI', | ||
'url': 'https://www.site.com/page/', | ||
} | ||
|
||
sends = { | ||
'method': 'cutcaptcha', | ||
'api_key': 'SAs61IAI', | ||
'misery_key': 'ad52c87af17e2ec09b8d918c9f00416b1cb8c320', | ||
'pageurl': 'https://www.site.com/page/', | ||
} | ||
|
||
return self.send_return(sends, self.solver.cutcaptcha, **params) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import unittest | ||
|
||
try: | ||
from .abstract import AbstractTest | ||
except ImportError: | ||
from abstract import AbstractTest | ||
|
||
|
||
class FriendlyCaptchaTest(AbstractTest): | ||
|
||
def test_all_params(self): | ||
params = { | ||
'sitekey': 'FCMGEMUD2KTDSQ5H', | ||
'url': 'https://friendlycaptcha.com/demo', | ||
} | ||
|
||
sends = { | ||
'method': 'friendly_captcha', | ||
'sitekey': 'FCMGEMUD2KTDSQ5H', | ||
'pageurl': 'https://friendlycaptcha.com/demo', | ||
} | ||
|
||
return self.send_return(sends, self.solver.friendly_captcha, **params) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import unittest | ||
|
||
try: | ||
from .abstract import AbstractTest | ||
except ImportError: | ||
from abstract import AbstractTest | ||
|
||
|
||
class MTCaptchaTest(AbstractTest): | ||
|
||
def test_all_params(self): | ||
params = { | ||
'sitekey': 'MTPublic-KzqLY1cKH', | ||
'url': 'https://2captcha.com/demo/mtcaptcha', | ||
} | ||
|
||
sends = { | ||
'method': 'mt_captcha', | ||
'sitekey': 'MTPublic-KzqLY1cKH', | ||
'pageurl': 'https://2captcha.com/demo/mtcaptcha', | ||
} | ||
|
||
return self.send_return(sends, self.solver.mtcaptcha, **params) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.