Пример #1
0
async def work(pageurl, sitekey, loop):
    asyncio.set_event_loop(loop)
    while 1:
        fut = asyncio.run_coroutine_threadsafe(proxies.get(), main_loop)
        proxy = fut.result()
        options = {"ignoreHTTPSErrors": True, "args": ["--timeout 5"]}
        client = Solver(
            pageurl,
            sitekey,
            options=options,
            proxy=proxy,
            loop=loop,
        )
        try:
            task = loop.create_task(client.start())
            await task
            with suppress(BaseException):
                task.exception()
        except CancelledError:
            break
        else:
            result = task.result()
            if result:
                if result['status'] == "detected":
                    asyncio.run_coroutine_threadsafe(proxies.set_banned(proxy),
                                                     main_loop)
                else:
                    if result['status'] == "success":
                        return result['code']
Пример #2
0
async def work(pageurl, sitekey, task_id):

    # Chromium options and arguments
    options = {"ignoreHTTPSErrors": True, "args": ["--timeout 5"]}

    async with sem:
        while True:
            if proxy_source:
                proxy = random.choice(proxies)
            else:
                proxy = None

            client = Solver(pageurl, sitekey, options=options, proxy=proxy)
            task = asyncio.ensure_future(client.start())
            await task
            result = task.result()
            if result:
                break

        tasks.update({task_id: {"status": "finished", "solution": result}})
Пример #3
0
import asyncio
import sys

from nonocaptcha.solver import Solver

if len(sys.argv) == 4:
    pageurl, sitekey, proxy = sys.argv[1:]
else:
    print('Invalid number of arguments (pageurl, sitekey, proxy)')
    sys.exit(0)


loop = asyncio.get_event_loop()
options = {"ignoreHTTPSErrors": True, "args": ["--timeout 5"]}
if proxy.lower() == "none":
    proxy = None
client = Solver(pageurl, sitekey, options=options, proxy=proxy)
try:
    result = loop.run_until_complete(client.start())
except asyncio.CancelledError:
    raise
else:
    if result:
        print(result)
Пример #4
0
# for i in range(21, 35):
#     print("http://xunleib.zuida360.com/1805/逆缘国语-"+str(i).zfill(2)+".mp4")

import asyncio
from nonocaptcha.solver import Solver

pageurl = "https://www.google.com/recaptcha/api2/demo"
sitekey = "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"

proxy = "127.0.0.1:1000"
auth_details = {"username": "******", "password": "******"}
args = ["--timeout 5"]
options = {"ignoreHTTPSErrors": True, "args": args}
client = Solver(
    pageurl,
    sitekey,
    options=options,
    proxy=proxy,
    proxy_auth=auth_details,
)

solution = asyncio.get_event_loop().run_until_complete(client.start())
if solution:
    print(solution)
Пример #5
0
def signal_handler(signal, frame):
    asyncio.ensure_future(kill_chrome())


signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGHUP, signal_handler)

try:
    proxy_auth = {"username": proxy_username,
                  "password": proxy_password}
    options = {"ignoreHTTPSErrors": True, "args": ["--timeout 5"]}
    client = Solver(
        pageurl,
        sitekey,
        options=options,
        proxy=proxy,
        proxy_auth=proxy_auth
    )
    result = asyncio.get_event_loop().run_until_complete(
        client.start()
    )
except asyncio.CancelledError:
    asyncio.get_event_loop().run_until_complete(
        kill_chrome()
    )
else:
    if result:
        print(result)