twitter-api-client
twitter-api-client copied to clipboard
json error when using pagination
When I use pagination of twitter followers, it shows Cannot parse JSON response 'str' object has no attribute 'json'
. I think it's about pagination's merge.
I found that exception is in util.py
:
def get_json(res: list[Response], **kwargs) -> list:
cursor = kwargs.get('cursor')
temp = res
if any(isinstance(r, (list, tuple)) for r in res):
temp = flatten(res)
results = []
for r in temp:
try:
data = r.json()
if cursor:
results.append([data, cursor])
else:
results.append(data)
except Exception as e:
print('Cannot parse JSON response', e)
return results
I find that the cursor
is considered as element in temp
.
I print temp
:
temp: [<Response [200 OK]>, '1719229905266413416|1705851066710490964']
But cursor
cannot trans to json
so cause this exception.
Same problem