poe-api icon indicating copy to clipboard operation
poe-api copied to clipboard

AttributeError: 'NoneType' object has no attribute 'group'

Open manm15 opened this issue 1 year ago • 3 comments

Got an error, I don't know why. I have already checked multiple issues on this github but why won't it work?

Traceback (most recent call last): File "C:/Users/ManM15/OneDrive - Berkhamsted Schools Group/Documents/Code/Poe.py", line 3, in <module> client = poe.Client("FQvugE1iK7jI0BKGrReYBQ%3D%3D") File "C:\Users\ManM15\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\poe.py", line 123, in __init__ self.connect_ws() File "C:\Users\ManM15\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\poe.py", line 365, in connect_ws self.setup_connection() File "C:\Users\ManM15\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\poe.py", line 149, in setup_connection self.next_data = self.get_next_data(overwrite_vars=True) File "C:\Users\ManM15\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\poe.py", line 193, in get_next_data json_text = re.search(json_regex, r.text).group(1) AttributeError: 'NoneType' object has no attribute 'group'

manm15 avatar Jun 13 '23 10:06 manm15

hit the same error, because the content of the page returned by requesting poe.com is garbled, leading to no regular matching :

    r = request_with_retries(self.session.get, self.home_url)
    json_regex = r'<script id="__NEXT_DATA__" type="application\/json">(.+?)</script>'
    json_text = re.search(json_regex, r.text).group(1)

r.content: b'\x1f\xef\xbf\xbd\x08\x00\x00\x00\....'

The reason why the content is grbled may be the response content is compressed by gzip, you need to decompress it first.

'Content-Encoding': 'gzip'

riusksk avatar Jul 12 '23 09:07 riusksk

got the same error, is there any help?

asce0 avatar Jul 23 '23 14:07 asce0

same here from yday. even tried different account and token. still same error!

monshizadeh avatar Jul 24 '23 15:07 monshizadeh