Coder Social home page Coder Social logo

Comments (12)

Hecbi avatar Hecbi commented on May 20, 2024 4

他的默认代理检测器找不到clash代理,需要修改他的代码,分为两部分:

  1. http代理:修改api.py的__init__ 如下:
def __init__(self, cookie: str, proxy: bool=False):
        self.cookie = cookie
        self.formkey = None
        if proxy == True and PROXY == True:
            # proxies = fetch_proxy()
            # for p in range(len(proxies)):
            try:
                self.proxy = {
                    "http://": "socks5://127.0.0.1:7890",
                    "https://": "socks5://127.0.0.1:7890",
                }
                self.client = Client(headers=self.HEADERS, timeout=180, proxies=self.proxy)
                # logger.info(f"Connection established with {proxies[p]}")
                logger.info("代理连接成功")
                # break
            except:
                # logger.info(f"Connection failed with {proxies[p]}. Trying {p+1}/{len(proxies)} ...")
                logger.error("代理错误")
                sleep(1)
        else:
            self.proxy = None
            self.client = Client(headers=self.HEADERS, timeout=180)
        self.client.cookies.update({'m-b': self.cookie})
        
        self.get_channel_settings()
        
        logger.info("Connection established with poe.com")
        
        self.ws_connecting = False
        self.ws_connected = False
        self.ws_error = False
        self.active_messages = {}
        self.message_queues = {}
        self.current_thread = {}
        self.retry_attempts = 3
        self.message_generating = True
        self.ws_refresh = 3
        self.groups = {}
        
        self.connect_ws()
  1. websocket代理:修改api.py的ws_run_thread函数如下:
    def ws_run_thread(self):
        if not self.ws.sock:
            kwargs = {"sslopt": {"cert_reqs": ssl.CERT_NONE}, "http_proxy_host":"127.0.0.1", "http_proxy_port": 10808, "proxy_type": "socks5"}
            self.ws.run_forever(**kwargs)

这个方法对我好用

from poe-api-wrapper.

srcao-bingo avatar srcao-bingo commented on May 20, 2024

I installed poe_api_wrapper[proxy]. My operating system is Win11, and the Python version is 3.9.12

from poe-api-wrapper.

snowby666 avatar snowby666 commented on May 20, 2024

Well there was no proxy at that moment. My unit test still works

from poe-api-wrapper.

srcao-bingo avatar srcao-bingo commented on May 20, 2024

Did you enable Clash or other proxy software when testing? I keep Clash on when running the sample code. If I turn off Clash, I can't access Poe.com.

from poe-api-wrapper.

srcao-bingo avatar srcao-bingo commented on May 20, 2024

下载_00

from poe-api-wrapper.

snowby666 avatar snowby666 commented on May 20, 2024

i cant help beyond that then since it depends on ballyregan for auto-proxy method. Can you use the lib with just client = PoeApi(token)?

from poe-api-wrapper.

srcao-bingo avatar srcao-bingo commented on May 20, 2024

I still can't use it.

client = PoeApi(token)
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\poe_api_wrapper\api.py", line 124, in init
'Quora-Formkey': self.get_formkey,
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\poe_api_wrapper\api.py", line 144, in get_formkey
response = self.client.get(self.BASE_URL, headers=self.HEADERS, follow_redirects=True)
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\httpx_client.py", line 1041, in get
return self.request(
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\httpx_client.py", line 814, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\httpx_client.py", line 901, in send
response = self._send_handling_auth(
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\httpx_client.py", line 929, in _send_handling_auth
response = self._send_handling_redirects(
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\httpx_client.py", line 966, in _send_handling_redirects
response = self._send_single_request(request)
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\httpx_client.py", line 1002, in _send_single_request
response = transport.handle_request(request)
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\httpx_transports\default.py", line 218, in handle_request
resp = self._pool.handle_request(req)
File "D:\software\anaconda\lib\contextlib.py", line 137, in exit
self.gen.throw(typ, value, traceback)
File "C:\Users\cao\AppData\Roaming\Python\Python39\site-packages\httpx_transports\default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError: EOF occurred in violation of protocol (_ssl.c:1129)

from poe-api-wrapper.

srcao-bingo avatar srcao-bingo commented on May 20, 2024

I lowered the version of urllib3 to 1.25.11 and solved the above problem. It shows that the connection is established but another problem occurs. Have you ever encountered this situation?
2023-09-16_19-27-36

from poe-api-wrapper.

llllly26 avatar llllly26 commented on May 20, 2024

I lowered the version of urllib3 to 1.25.11 and solved the above problem. It shows that the connection is established but another problem occurs. Have you ever encountered this situation? 2023-09-16_19-27-36

请问你的问题解决了吗

from poe-api-wrapper.

srcao-bingo avatar srcao-bingo commented on May 20, 2024

I lowered the version of urllib3 to 1.25.11 and solved the above problem. It shows that the connection is established but another problem occurs. Have you ever encountered this situation? 2023-09-16_19-27-36

请问你的问题解决了吗

今天重新装了一遍,还是同样的问题,换换别的库吧,别在一棵树上吊死。
image

from poe-api-wrapper.

srcao-bingo avatar srcao-bingo commented on May 20, 2024

@Hecbi 首先非常感谢您的分享,我今晚尝试后也能正确识别代理,不过仍存在下面这个问题
image
我分别使用了quora.com 和 poe.com 最新的 token ,也更新了 poe-api-wrapper ,我不太清楚是什么原因导致该问题。如果您曾遇到过相似的问题,方便分享一下您是如何解决的吗?

from poe-api-wrapper.

srcao-bingo avatar srcao-bingo commented on May 20, 2024

@Hecbi 首先非常感谢您的分享,我今晚尝试后也能正确识别代理,不过仍存在下面这个问题 image 我分别使用了quora.com 和 poe.com 最新的 token ,也更新了 poe-api-wrapper ,我不太清楚是什么原因导致该问题。如果您曾遇到过相似的问题,方便分享一下您是如何解决的吗?

找到原因了,def ws_run_thread(self) 中的 "http_proxy_port"这个端口号需要修改成自己的端口。
终于可以愉快的玩耍了,再次感谢!

from poe-api-wrapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.