Skip to content

Commit 93b4659

Browse files
Update Linkedin_Posts_Scrapper.py
1 parent 0507fef commit 93b4659

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import requests
2+
3+
def get_linkedin_posts(access_token):
4+
url = 'https://api.linkedin.com/v2/shares?q=owners&owners=urn:li:person:YOUR_USER_ID&count=10'
5+
headers = {'Authorization': f'Bearer {access_token}'}
6+
7+
response = requests.get(url, headers=headers)
8+
data = response.json()
9+
10+
if response.status_code == 200:
11+
posts = data.get('elements', [])
12+
for post in posts:
13+
post_text = post.get('text', '')
14+
print(post_text)
15+
else:
16+
print(f"Error: {response.status_code} - {data.get('message', 'Unknown error')}")
17+
18+
if __name__ == "__main__":
19+
# Replace YOUR_ACCESS_TOKEN and YOUR_USER_ID with appropriate values
20+
access_token = "YOUR_ACCESS_TOKEN"
21+
get_linkedin_posts(access_token)

0 commit comments

Comments
 (0)