jupyter-naas / awesome-notebooks

A powerful data & AI notebook templates catalog: prompts, plugins, models, workflow automation, analytics, code snippets - following the IMO framework to be searchable and reusable in any context.
https://naas.ai/search
BSD 3-Clause "New" or "Revised" License
2.64k stars 445 forks source link

LinkedIn - Update metrics from posts in Notion content calendar: Exceeded redirects error #1719

Closed TMobbsFR closed 1 year ago

TMobbsFR commented 1 year ago

Exceeded redirects error, Exceeded 30 redirects. When running the get updated posts piece of code I get the exceeded redirects error.

Full error message below

TooManyRedirects Traceback (most recent call last)

in 38 39 ---> 40 df_update = get_last_posts(df_posts, csv_output) 41 df_update in get_last_posts(df_posts, csv_output, key, no_posts, min_updated_time) 24 return df_new 25 else: ---> 26 df_new = linkedin.connect(LI_AT, JSESSIONID).profile.get_posts_feed( 27 PROFILE_URL, limit=-1 28 ) /opt/conda/lib/python3.9/site-packages/naas_drivers/tools/linkedin.py in get_posts_feed(self, profile_url, profile_id, count, limit, until, sleep, pagination_token) 502 # Get profile 503 if profile_id is None: --> 504 profile_id = LinkedIn.get_profile_urn(self, profile_url) 505 if profile_id is None: 506 return "Please enter a valid profile_url or profile_urn" /opt/conda/lib/python3.9/site-packages/naas_drivers/tools/linkedin.py in get_profile_urn(self, url) 94 def get_profile_urn(self, url): 95 lk_id = self.get_profile_id(url) ---> 96 res = requests.get( 97 f"[https://www.linkedin.com/voyager/api/identity/profiles/{lk_id](https://www.linkedin.com/voyager/api/identity/profiles/%7Blk_id)}", 98 cookies=self.cookies, /opt/conda/lib/python3.9/site-packages/requests/api.py in get(url, params, **kwargs) 73 """ 74 ---> 75 return request('get', url, params=params, **kwargs) 76 77 /opt/conda/lib/python3.9/site-packages/requests/api.py in request(method, url, **kwargs) 59 # cases, and look like a memory leak in others. 60 with sessions.Session() as session: ---> 61 return session.request(method=method, url=url, **kwargs) 62 63 /opt/conda/lib/python3.9/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) 540 } 541 send_kwargs.update(settings) --> 542 resp = self.send(prep, **send_kwargs) 543 544 return resp /opt/conda/lib/python3.9/site-packages/requests/sessions.py in send(self, request, **kwargs) 675 # Redirect resolving generator. 676 gen = self.resolve_redirects(r, request, **kwargs) --> 677 history = [resp for resp in gen] 678 else: 679 history = [] /opt/conda/lib/python3.9/site-packages/requests/sessions.py in (.0) 675 # Redirect resolving generator. 676 gen = self.resolve_redirects(r, request, **kwargs) --> 677 history = [resp for resp in gen] 678 else: 679 history = [] /opt/conda/lib/python3.9/site-packages/requests/sessions.py in resolve_redirects(self, resp, req, stream, timeout, verify, cert, proxies, yield_requests, **adapter_kwargs) 164 165 if len(resp.history) >= self.max_redirects: --> 166 raise TooManyRedirects('Exceeded {} redirects.'.format(self.max_redirects), response=resp) 167 168 # Release the connection back into the pool. TooManyRedirects: Exceeded 30 redirects.
FlorentLvr commented 1 year ago

@TMobbsFR, the message means you exceed the number calls allowed by LinkedIn.

Please note that this code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Linkedin or any of its affiliates or subsidiaries. It uses an independent and unofficial API. Use at your own risk.

This project violates Linkedin's User Agreement Section 8.2, and because of this, Linkedin may (and will) temporarily or permanently ban your account. We are not responsible for your account being banned.