Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--proxy failed for auth proxy #86

Closed
ClericPy opened this issue Apr 6, 2022 · 9 comments
Closed

--proxy failed for auth proxy #86

ClericPy opened this issue Apr 6, 2022 · 9 comments
Labels
question Further information is requested

Comments

@ClericPy
Copy link
Owner

ClericPy commented Apr 6, 2022

Some proxy have the auth information like: http://username:password@host:port

@ClericPy ClericPy added the question Further information is requested label Apr 6, 2022
@ClericPy
Copy link
Owner Author

ClericPy commented Apr 6, 2022

Standard Chrome CDP didn't support that type of proxy, so we should get a solution from Fetch.enable

async def handler(tab: AsyncTab):
    async with tab.iter_fetch(
        [{
            'urlPattern': '*',
            'requestStage': 'Request'
        }],
            handleAuthRequests=True,
    ) as f:
        async for i in f:
            print(i)
            if i['method'] == 'Fetch.authRequired':
                await f.continueWithAuth(
                    i,
                    'ProvideCredentials',
                    'username',
                    'password',
                )
            else:
                await f.continueRequest(i)

To filter those requests of proxy auth required, check the Fetch.AuthChallenge and find the source==Proxy

PS: Fetch context could not be used twice in the same tab.

@ClericPy
Copy link
Owner Author

Or use gost

https://github.com/ginuerzh/gost/blob/master/README_en.md

gost -L 127.0.0.1:9999 -F http://xxx@xxx:a.com/

port-forwarding proxy for chrome, python3 -m ichrome --proxy=http://127.0.0.1:9999

@ClericPy
Copy link
Owner Author

./gost -L=user:pwd@127.0.0.1:10800

import asyncio

from ichrome import AsyncChromeDaemon


async def main():
    async with AsyncChromeDaemon(proxy='http://127.0.0.1:10800',
                                 clear_after_shutdown=True,
                                 headless=1) as cd:
        async with cd.connect_tab() as tab:
            await tab.pass_auth_proxy('user', 'pwd')
            await tab.goto('http://httpbin.org/ip', timeout=2)
            print(await tab.html)


asyncio.run(main())

@why2lyj
Copy link
Contributor

why2lyj commented Feb 22, 2023

Windows环境好像不支持 https 的 auth proxy

@ClericPy
Copy link
Owner Author

Windows环境好像不支持 https 的 auth proxy

没试 https 的代理, 实在不行就走 gost 转发算了, 折腾不动了

@why2lyj
Copy link
Contributor

why2lyj commented Feb 22, 2023

Windows环境好像不支持 https 的 auth proxy

没试 https 的代理, 实在不行就走 gost 转发算了, 折腾不动了

给个方法呗,我看看能不能补全。

@ClericPy
Copy link
Owner Author

Windows环境好像不支持 https 的 auth proxy

没试 https 的代理, 实在不行就走 gost 转发算了, 折腾不动了

给个方法呗,我看看能不能补全。

啥方法啊... 上面的评论是我所有尝试的手段了..

@why2lyj
Copy link
Contributor

why2lyj commented Mar 3, 2023

我更正一下,可能是IPv6的auth proxy不支持,IPv4的auth proxy可以。因为我用得代理很特殊。

@ClericPy
Copy link
Owner Author

ClericPy commented Mar 3, 2023

我更正一下,可能是IPv6的auth proxy不支持,IPv4的auth proxy可以。因为我用得代理很特殊。

原生 chrome 命令行的 proxy 就只支持 http 不支持 https, 而且还不支持带 http basic auth 的, 更别说 ipv6 了, 用 gost 直接丢子进程里转发算了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants