lips2
New member
I'm trying to use 2captcha for bypassing captcha while scraping a category of products at wayfair.com The code I'm using is;
the error I'm getting in VS code is here
I'm struggling to know what is the actual problem, how to get away with it, and let the 2captcha solve the captchas while scraping. Thanks
Code:
def parse(self,response):
l=[]
resp3 = Selector(text=self.driver.page_source)
self.driver.get("https://www.wayfair.com/filters/storage-organization/sb6/closet-systems-c1833181-a72947~471760-a72947~471761-a72947~471762-a72947~471763-a72947~493985-a72947~494649.html")
our_condition = resp3.xpath('//span[@class="BrowseHeaderWithSort-roadsign"]/text()').get()
# if resp3.xpath('//div[@class="g-recaptcha"]').get() != None:
if our_condition in ['Closet Systems']:
print('/////30 sec/////')
time.sleep(2)
else:
print('captcha detected')
time.sleep(60)
while True:
api_key = '4f4796f8w4782b0d45621897818c7d58e'
site_key = '6LfaBQEaAAAAAG8Z0xFqTFgOykhR3HmCEPlImW2T' # grab from site
client = AnticaptchaClient(api_key)
task = NoCaptchaTaskProxylessTask(self.driver.current_url, site_key)
while True:
job = client.createTask(task)
print("Waiting for solution")
job.join()
response = job.get_solution_response()
print("captcha solution", response)
if len(response) > 0:
break
print('injecting the token on html')
self.driver.execute_script(f'document.getElementById("g-recaptcha-response").innerHTML="{response}";')
print('injecting the token on html. Success!')
time.sleep(3)
self.driver.find_element_by_xpath('//button[@class="submit"]').click()
time.sleep(3)
resp = Selector(text=self.driver.page_source)
if resp.xpath('//div[@class="g-recaptcha"]/@data-site-key').get() == None:
break
the error I'm getting in VS code is here
raise AnticaptchaException( python_anticaptcha.exceptions.AnticaptchaException: [ERROR_KEY_DOES_NOT_EXIST:1]Account authorization key not found in the system 2021-03-02 19:10:09 [scrapy.extensions.logstats]
I'm struggling to know what is the actual problem, how to get away with it, and let the 2captcha solve the captchas while scraping. Thanks