M Kumar
M Kumar

Reputation: 43

How to get Linkedin post URN from website

Is there a way to get a Linkedin post's url in the below format from the website:

https://www.linkedin.com/feed/update/urn:li:activity:xxxxxxxxxxxxxxxxxxx/

Upvotes: 2

Views: 2699

Answers (1)

Esref
Esref

Reputation: 366

There is a hacky way I have found. It turns out, you can find it on the page source. Here is an example of how I got it:

>>> import requests
>>> post_link = 'https://www.linkedin.com/posts/activity-6453360792111718400-0j6d'
>>> response = requests.get(post_link).text
>>> urn_index = response.index('urn:li:activity:')
>>> finish_index = response.index('"', urn_index)
>>> activity_urn = response[urn_index:finish_index]
>>> print(f'https://www.linkedin.com/feed/update/{activity_urn}')
https://www.linkedin.com/feed/update/urn:li:activity:6453360792111718400

I don't think that's a stable method but I also couldn't find any other way with the Linkedin API.

Upvotes: 3

Related Questions