Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RC-2600-add-tencent-method #80

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions examples/tencent.py
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.tencent(
app_id="197322596",
url="https://www.holla.world/random-video-chat#app"
)

except Exception as e:
sys.exit(e)

else:
sys.exit('result: ' + str(result))
42 changes: 42 additions & 0 deletions examples/tencent_options.py
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.tencent(app_id="197325555",
url="https://your.site/result-receiver",
# proxy={
# 'type': 'HTTPS',
# 'uri': 'ub6900fef552505bc-zone-custom-session-JcIHpmDKv-sessTime-1:[email protected]:2333'
# }
)

except Exception as e:
sys.exit(e)

else:
sys.exit('result: ' + str(result))
29 changes: 29 additions & 0 deletions tests/test_tencent.py
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 TencentTest(AbstractTest):

def test_all_params(self):
params = {
"app_id": "197322596",
"url": "https://www.holla.world/random-video-chat#app"
}

sends = {
"method": "tencent",
"app_id": "197322596",
"pageurl": "https://www.holla.world/random-video-chat#app",
}

return self.send_return(sends, self.solver.tencent, **params)


if __name__ == '__main__':
unittest.main()
26 changes: 26 additions & 0 deletions twocaptcha/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,32 @@ def friendly_captcha(self, sitekey, url, **kwargs):
**kwargs)
return result

def tencent(self, app_id, url, **kwargs):
'''Wrapper for solving Tencent captcha.

Parameters
__________
app_id : str
The value of appId parameter in the website source code.
url : str
The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is
available only for authenticated users.
softId : int, optional
ID of software developer. Developers who integrated their software with 2Captcha get reward: 10% of
spendings of their software users.
callback : str, optional
URL for pingback (callback) response that will be sent when captcha is solved. URL should be registered on
the server. More info here https://2captcha.com/2captcha-api#pingback.
proxy : dict, optional
{'type': 'HTTPS', 'uri': 'login:password@IP_address:PORT'}.
'''

result = self.solve(app_id=app_id,
url=url,
method="tencent",
**kwargs)
return result

def cutcaptcha(self, misery_key, apikey, url, **kwargs):
'''
Wrapper for solving Friendly Captcha
Expand Down