我试图在wayfair.com上使用2captcha绕过验证码,同时删除一类产品 我使用的代码是
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
我在VS代码中遇到的错误在这里
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]
我努力想知道实际的问题是什么,如何摆脱它,让2captcha在抓取的同时解决CAPTCHA。谢谢
目前没有回答
相关问题 更多 >
编程相关推荐