ad-m / python-anticaptcha

Client library for solve captchas with Anticaptcha.com support.
http://python-anticaptcha.readthedocs.io/en/latest/
MIT License
223 stars 51 forks source link

How to use Funcaptcha with proxy ? #85

Closed MacMarde closed 4 years ago

MacMarde commented 4 years ago

@ad-m

From your examples I tried to use Funcaptcha with proxy like this:

from python_anticaptcha import AnticaptchaClient, FunCaptchaTask, Proxy

proxy = Proxy.parse_url("socks5://login:password@123.123.123.123")

But it is not possible to import "Proxy" from python_anticaptcha I am using the latest version from pip

I also tried to use some code from your example "funcaptcha_selenium.py ":

proxy_urls = environ["PROXY_URL"].split(",")

But I do also get an error. "PROXY_URL" does not exist.

I do know my proxy IP and port, but how do I enter it correctly so that I can pass it to "FunCaptchaTask"?

Any help?

MacMarde commented 4 years ago

Ok I got it. It seems to work like this:

from six.moves.urllib import parse

proxy="123.123.123.123:9190"
proxy= parse_url("http://" + proxy)
task = FunCaptchaTask(browser.current_url, public_key, user_agent=user_agent, **proxy)

def parse_url(url):
    parsed = parse.urlparse(url)
    return dict(
        proxy_type=parsed.scheme,
        proxy_address=parsed.hostname,
        proxy_port=parsed.port,
        proxy_login=parsed.username,
        proxy_password=parsed.password,
    )