Herkese merhaba arkadaşlar.Konuyu daha önce açmıştım ancak yanlış yere açmışım. Belki burda bir çözüm bulunur diye tekrar açıyorum.

Kod şöyle:

while True:

username_box = self.driver.find_element_by_xpath(
'//*[@id="snapname"]')
username_box.send_keys('nicolehanso2020')
sleep(2)
age_select = Select(self.driver.find_element_by_id('age'))
age_select.select_by_value(random.choice(age_values))
sleep(2)
gender_select = Select(self.driver.find_element_by_id('gender'))
gender_select.select_by_value('female')
sleep(2)
add_me_btn = self.driver.find_element_by_id('submitBtn')
add_me_btn.click()

sleep(2)

try:

logout = self.driver.find_element_by_xpath(
'//*[@id="wrap"]/div[1]/div/div[2]/ul/li/a')
logout.click()
sleep(2)
logout1 = self.driver.find_element_by_xpath(
"//*[@id='wrap']/div[1]/div/div[2]/ul/li/ul/li/a")
logout1.click()
sleep(5)

except:

service_key = 'xxxxx'
google_site_key = 'xxxxxx'
pageurl = 'https://www.addmesnaps.com/recaptcha.php'
url = "http://2captcha.com/in.php?key=xxxx&method=userrecaptcha&googlekey=xxxxx&pageurl=https://www.addmesnaps.com/recaptcha.php"
resp = requests.get(url)
if resp.text[0:2] != 'OK':
quit('Service error. Error Code' + resp.text)
captcha_id = resp.text[3:]
fetch_url = "http://2captcha.com/res.php?key=0df2f19f63f57154676dc3ff9daa3010&action=get&id=" + captcha_id
for i in range(1, 20):
sleep(5)
resp = requests.get(fetch_url)
if resp.text[0:2] == 'OK':
break
print('Time to solve:', time() - start_time)
submit_url = "https://www.addmesnaps.com/recaptcha.php"
headers = {
'user-agent': 'Mozilla/5.0 Chrome/52.0.2743.116 Safari/537.36'}
payload = {
'submit': 'submit',
'g-recaptcha-response': resp.text[3:]
}
resp = requests.post(submit_url, headers=headers, data=payload)

finally:

counter = 0
print('It is the {}. time'.format(counter))
counter += 1
sleep(20)
Kod şu satıra kadar sıkıntısız çalıyor.
submit_url = "https://www.addmesnaps.com/recaptcha.php"
ama bundan sonra captchayı çözmeden while döngüsünün başına dönüyor. Neden olabilir?