· 4 years ago · Mar 22, 2021, 09:34 PM
1from selenium import webdriver
2import time
3import random
4from selenium import webdriver
5from selenium.webdriver.common.keys import Keys
6from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask
7import json
8
9import requests
10
11min = 0.05
12max = 0.3
13
14# options.add_argument('-headless')
15
16chrome_options = webdriver.ChromeOptions()
17chrome_options.add_argument("user-data-dir=selenium")
18driver = webdriver.Chrome(options=chrome_options)
19
20driver.get('https://discordbotlist.com/bots/statman/upvote')
21
22
23def sendCaptcha():
24 print('here')
25 data = {
26 'key': '', # Insert 2Captcha API Key Here.
27 'method': 'userrecaptcha',
28 'googlekey': '6LeDt_AUAAAAAHnBLEMy7xTuc6K4xz1SPKChnuCa',
29 'pageurl': 'https://discordbotlist.com/bots/statman/upvote',
30 'invisible': 0,
31 'json': 1,
32 'min_score': 0.2
33 }
34 try:
35 sc = requests.post('https://2captcha.com/in.php', data=data)
36 j = json.loads(sc.text)
37 print(f"J IS ====== {j}")
38 except Exception as e:
39 print(e)
40 return 1
41 if j['status'] == 1:
42 return j['request']
43
44
45def getCaptcha(cid):
46 print('here1')
47 try:
48 gc = requests.get(
49 'https://2captcha.com/res.php?key={0}&action=get&id={1}&json=1'.format('',
50 cid))
51 print(f"cid = {cid}")
52 print(f"GC = {gc.text}")
53 j = json.loads(gc.text)
54 print(f"J ==== {j}")
55 except:
56 return 2
57 if j['status'] == 1:
58 print(f"J REQUEST1 = {j['request']}")
59 return j['request']
60 elif j['status'] == 0:
61 if j['request'] == 'CAPTCHA_NOT_READY':
62 print(f"J REQUEST2 = {j['request']}")
63 return 1
64 elif j['request'] == 'ERROR_CAPTCHA_UNSOLVABLE':
65 print(f"J REQUEST3 = {j['request']}")
66 return 3
67 else:
68 print(f"J ==== {j}")
69 return 3
70
71 print(f"J REQUEST4 = {j['request']}")
72 print(f"J = {j}")
73 return 2
74
75
76a = True
77time.sleep(2)
78idid = sendCaptcha()
79time.sleep(20)
80while a:
81 print('A')
82 get = getCaptcha(idid)
83 print(f"idid = {idid}")
84 time.sleep(5)
85 print(get)
86 if get != 3:
87 print('B')
88 a = False
89 respxp = r'//*[@id="g-recaptcha-response"]'
90 getstr = str(get)
91 print(f"getstring = {getstr}")
92 my = 'document.getElementById("g-recaptcha-response").innerHTML = \"' + getstr + '\";'
93 driver.execute_script(my)
94 time.sleep(3)
95 print('c')
96
97 driver.find_element_by_xpath('//*[@id="__layout"]/div/div[1]/div/div/div[2]/button').click()
98