tomquirk / linkedin-api

👨‍💼 LinkedIn API for Python
https://pypi.org/project/linkedin-api
MIT License
2.18k stars 461 forks source link

Pagination Error #277

Open Jaykingamez opened 1 year ago

Jaykingamez commented 1 year ago

For example let's say I'm tried to get the comments on this post,

{'author_name': 'Jayme Metcalfe, FCIIS, CISSP, CISA', 'author_profile': 'https://www.linkedin.com/in/81989927', 'old': '3h •   ', 'content': "It's not often you see Google caught flat-footed on the tech front, but #ChatGPT certainly has done so. Search has in many ways remained stagnant for quite a while, and is ripe for disruption. #innovation #ai", 'url': 'https://www.linkedin.com/feed/update/urn:li:activity:7028223049875296256'}   

Assuming that the post has no comments, then doing, api.get_post_comments should return nothing. Unfortunately, the following error is obtained. Since a post with no comments would lack a paginationToken, an exception is generated.

linkedin_api\linkedin.py", line 171, in get_post_comments
    while data and data["metadata"]["paginationToken"] != "":
KeyError: 'paginationToken'

How it should work:

There should not be an exception, and an empty json is returned.

Njoselson commented 1 year ago

These tests are failing for feed posts:

FAILED tests/test_linkedin_api_requests.py::test_get_feed_posts_pagination - TypeError: argument o...
FAILED tests/test_linkedin_api_requests.py::test_get_feed_posts_urns_contains_no_duplicated - Asse...