здесь полные журналы ошибок
line 514, in wrap_api_call
raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
ValueError: Page.evaluate: The future belongs to a different loop than the one specified as the loop argument
Я пытаюсь нажать кнопку «Отправить» после получения ответа от API. мой полный код
import scrapy
from anticaptchaofficial.recaptchav2proxyless import recaptchaV2Proxyless
from scrapy_playwright.page import PageMethod
class RecaptchaSpider(scrapy.Spider):
name = "recaptcha_spider"
start_urls = ["https://www.google.com/recaptcha/api2/demo"]
delay_after_submit = 5 # Time in seconds to wait after submit
def start_requests(self):
for url in self.start_urls:
yield scrapy.Request(
url,
dont_filter=True,
meta={
"playwright": True,
"playwright_include_page": True,
},
callback=self.solve_captcha,
)
async def solve_captcha(self, response):
# Step 1: Solve the CAPTCHA using AntiCaptcha API
api_key = "my api key" # Replace with your actual API key
solver = recaptchaV2Proxyless()
solver.set_key(api_key)
solver.set_website_url(response.url)
solver.set_website_key("6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-") # Replace with Google reCAPTCHA site key
captcha_solution = solver.solve_and_return_solution()
if captcha_solution:
self.logger.info(f"Solved CAPTCHA: {captcha_solution}")
# Step 2: Execute JavaScript to fill the CAPTCHA solution and click the submit button
page = response.meta["playwright_page"]
await page.evaluate(f'document.getElementById("g-recaptcha-response").innerHTML = "{captcha_solution}";') # Replace with the correct ID if different
await page.click("button[type='submit']") # Replace with the correct selector for the submit button
# Wait for the next page or any other action you want to perform
await page.wait_for_timeout(self.delay_after_submit)
# Step 3: Handle the next step after clicking submit (if necessary)
# You might want to retrieve the new page content here
new_content = await page.content()
self.logger.info("New page content after submit:")
self.logger.info(new_content)
else:
self.logger.error("Failed to solve CAPTCHA.")
Подробнее здесь: https://stackoverflow.com/questions/790 ... future-bel
Драматург Python Scrapy получает ошибку ValueError: Page.evaluate: будущее принадлежит другому циклу ⇐ Python
Программы на Python
1732571569
Anonymous
здесь полные журналы ошибок
line 514, in wrap_api_call
raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
ValueError: Page.evaluate: The future belongs to a different loop than the one specified as the loop argument
Я пытаюсь нажать кнопку «Отправить» после получения ответа от API. мой полный код
import scrapy
from anticaptchaofficial.recaptchav2proxyless import recaptchaV2Proxyless
from scrapy_playwright.page import PageMethod
class RecaptchaSpider(scrapy.Spider):
name = "recaptcha_spider"
start_urls = ["https://www.google.com/recaptcha/api2/demo"]
delay_after_submit = 5 # Time in seconds to wait after submit
def start_requests(self):
for url in self.start_urls:
yield scrapy.Request(
url,
dont_filter=True,
meta={
"playwright": True,
"playwright_include_page": True,
},
callback=self.solve_captcha,
)
async def solve_captcha(self, response):
# Step 1: Solve the CAPTCHA using AntiCaptcha API
api_key = "my api key" # Replace with your actual API key
solver = recaptchaV2Proxyless()
solver.set_key(api_key)
solver.set_website_url(response.url)
solver.set_website_key("6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-") # Replace with Google reCAPTCHA site key
captcha_solution = solver.solve_and_return_solution()
if captcha_solution:
self.logger.info(f"Solved CAPTCHA: {captcha_solution}")
# Step 2: Execute JavaScript to fill the CAPTCHA solution and click the submit button
page = response.meta["playwright_page"]
await page.evaluate(f'document.getElementById("g-recaptcha-response").innerHTML = "{captcha_solution}";') # Replace with the correct ID if different
await page.click("button[type='submit']") # Replace with the correct selector for the submit button
# Wait for the next page or any other action you want to perform
await page.wait_for_timeout(self.delay_after_submit)
# Step 3: Handle the next step after clicking submit (if necessary)
# You might want to retrieve the new page content here
new_content = await page.content()
self.logger.info("New page content after submit:")
self.logger.info(new_content)
else:
self.logger.error("Failed to solve CAPTCHA.")
Подробнее здесь: [url]https://stackoverflow.com/questions/79076276/python-scrapy-playwright-getting-error-valueerror-page-evaluate-the-future-bel[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия