Skip to content

Commit 7a3452b

Browse files
added affiliate_id
1 parent 65cc13a commit 7a3452b

File tree

4 files changed

+53
-38
lines changed

4 files changed

+53
-38
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,28 @@ balance = bcs.account_balance()
3939
**Submit image captcha**
4040

4141
``` python
42-
bcs.submit_image_captcha('captcha.jpg', False) # submit image captcha (case_sensitive param optional)
42+
bcs.submit_image_captcha({'image': 'your local image or URL', 'case_sensitive': False, 'affiliate_id': 'ID of affiliate'}) # submit image captcha (case_sensitive param optional)
4343
```
4444
The image submission works with both files and b64 encoded strings.
45-
Also for case-sensitive captchas, the 2nd parameter set to True, will make sure case is taken into account.
45+
Also for case-sensitive captchas, set the `case_sensitive` parameter to True, will make sure case is taken into account.
46+
For setting the affiliate_id, set the `affiliate_id` parameter
4647

4748
**Submit recaptcha details**
4849

4950
For recaptcha submission there are two things that are required.
5051
- page_url
5152
- site_key
53+
- type (optional)
54+
- v3_action (optional)
55+
- v3_min_score (optional)
56+
- user_agent (optional)
57+
- affiliate_id (optional)
5258
- proxy (optional)
59+
5360
``` python
54-
bcs.submit_recaptcha(PAGE_URL, SITE_KEY)
61+
bcs.submit_recaptcha({'page_url': 'page_url_here', 'site_key': 'sitekey_here')
5562
```
63+
5664
This method returns a captchaID. This ID will be used next, to retrieve the g-response, once workers have
5765
completed the captcha. This takes somewhere between 10-80 seconds.
5866

bestcaptchasolverapi3/bestcaptchasolverapi.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,32 @@ def account_balance(self):
3737
return '${}'.format(resp['balance'])
3838

3939
# solve normal captcha
40-
def submit_image_captcha(self, image_path, case_sensitive = False):
41-
data = dict(self._data)
40+
def submit_image_captcha(self, opts):
41+
data = {}
42+
data.update(self._data)
43+
44+
image_path = opts['image']
45+
# case sensitive
46+
if 'case_sensitive' in opts:
47+
if opts['case_sensitive']: data['case_sensitive'] = '1'
48+
# affiliate
49+
if 'affiliate_id' in opts:
50+
if opts['affiliate_id']: data['affiliate_id'] = opts['affiliate_id']
4251
url = '{}/captcha/image'.format(BASE_URL)
52+
4353
if os.path.exists(image_path):
4454
with open(image_path, 'rb') as f:
4555
data['b64image'] = b64encode(f.read())
4656
else:
47-
data['b64image'] = image_path # should be b64 already
48-
49-
if case_sensitive: data['case_sensitive'] = '1'
57+
data['b64image'] = image_path # should be b64 already
5058

5159
resp = self.POST(url, data)
52-
return resp['id'] # return ID
60+
return resp['id'] # return ID
5361

5462
# submit recaptcha to system
55-
# SET PROXY AS WELL
56-
# -------------------
57-
# ----------------------------------
58-
# ------------------------------
59-
def submit_recaptcha(self, page_url, site_key, proxy = None):
60-
# data parameters
61-
data = dict(self._data)
62-
data['page_url'] = page_url
63-
data['site_key'] = site_key
64-
65-
# check proxy and set dict (request params) accordingly
66-
if proxy: # if proxy is given, check proxytype
67-
# we have both proxy and type at this point
68-
data['proxy'] = proxy
69-
data['proxytype'] = 'HTTP'
70-
63+
def submit_recaptcha(self, data):
64+
data.update(self._data)
65+
if 'proxy' in data: data['proxy_type'] = 'HTTP' # add proxy, if necessary
7166
# make request with all data
7267
url = '{}/captcha/recaptcha'.format(BASE_URL)
7368
resp = self.POST(url, data)

captcha.jpg

15 KB
Loading

main.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
from bestcaptchasolverapi3.bestcaptchasolverapi import BestCaptchaSolverAPI
44
from time import sleep
55

6-
ACCESS_TOKEN = 'your_access_token'
7-
PAGE_URL = 'your_page_url'
8-
SITE_KEY = 'your_site_key'
6+
ACCESS_TOKEN = 'access_token_here'
7+
PAGE_URL = 'page_url_here'
8+
SITE_KEY = 'site_key_here'
99

1010

1111
# solve captcha
@@ -20,9 +20,12 @@ def test_api():
2020

2121
# solve image captcha
2222
# --------------------
23-
# works with URL as well, if authenticated with token
2423
print ('Solving image captcha ...')
25-
id = bcs.submit_image_captcha('captcha.jpg', False) # submit image captcha (case_sensitive param optional)
24+
data = {}
25+
data['image'] = 'captcha.jpg'
26+
# data['case_sensitive'] = True #, default: False
27+
# data['affiliate_id'] = 'affiliate_id from /account'
28+
id = bcs.submit_image_captcha(data) # submit image captcha (case_sensitive param optional)
2629
image_text = None
2730
# None is returned if completion is still in pending
2831
while image_text == None:
@@ -32,9 +35,23 @@ def test_api():
3235
print ('Captcha text: {}'.format(image_text))
3336

3437
# solve recaptcha
35-
# -----------------------------------------------------------------------------------------------
38+
# ---------------
3639
print ('Solving recaptcha ...')
37-
captcha_id = bcs.submit_recaptcha(PAGE_URL, SITE_KEY) # submit captcha first, to get ID
40+
data = {}
41+
data['page_url'] = PAGE_URL
42+
data['site_key'] = SITE_KEY
43+
44+
# other parameters
45+
# ----------------------------------------------------------------------
46+
# data['type'] = 1 # 1 - regular, 2 - invisible, 3 - v3, default 1
47+
# data['v3_action'] = 'v3 recaptcha action'
48+
# data['v3_min_score'] = '0.3'
49+
# data['user_agent'] = 'Your user agent'
50+
# data['proxy'] = '123.456.678:3031'
51+
# data['proxy'] = 'user:[email protected]:3031'
52+
# data['affiliate_id'] = 'affiliate_id from /account'
53+
captcha_id = bcs.submit_recaptcha(data) # submit captcha first, to get ID
54+
3855
# check if it's still in progress (waiting to be solved), every 10 seconds
3956
print ('Waiting for recaptcha to be solved ...')
4057
gresponse = None
@@ -44,14 +61,9 @@ def test_api():
4461
sleep(10) # sleep for 10 seconds and recheck
4562

4663
print ('Recaptcha response: {}'.format(gresponse)) # print google response
47-
#proxy_status = resp['proxy_status'] # get status of proxy
48-
49-
# bcs.submit_image_captcha('captcha.jpg', True) # case sensitive captcha image solving
50-
# bcs.submit_recaptcha(PAGE_URL, SITE_KEY, '123.45.67.89:3012') # solve through proxy
51-
# bcs.submit_recaptcha(PAGE_URL, SITE_KEY, 'user:[email protected]:3012') # solve through proxy with auth
64+
# proxy_status = resp['proxy_status'] # get status of proxy
5265
# bcs.set_captcha_bad(2) # set captcha with ID 2, bad
5366

54-
5567
# main method
5668
def main():
5769
try:

0 commit comments

Comments
 (0)