-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathinstagram.py
59 lines (56 loc) · 1.55 KB
/
instagram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import re
import requests
from instaloader import Instaloader, Post, Profile
L=Instaloader()
def userDetails(username):
try:
profile = Profile.from_username(L.context, username)
return profile
except Exception:
return None
def get_media_details(link):
link = link.split("?")[0]
shortcode = link.split('/p/')[1].replace('/', '')
post=Post.from_shortcode(L.context,shortcode)
owner_profile=post.owner_profile
full_name=owner_profile.full_name
followers=owner_profile.followers
followees=owner_profile.followees
is_verified=owner_profile.is_verified
is_private=owner_profile.is_private
bio=owner_profile.biography
external_url=owner_profile.external_url
owner_username=post.owner_username
url=post.url
caption=post.caption
caption_hashtags=post.caption_hashtags
if len(caption_hashtags)==0:
caption_hashtags=None
caption_mentions=post.caption_mentions
if len(caption_mentions)==0:
caption_mentions=None
is_video=post.is_video
video_url=post.video_url
if(is_video):
media_url=video_url
else:
media_url=url
likes=post.likes
comments=post.comments
return(full_name,
followers,
followees,
is_verified,
is_private,
bio,
external_url,
owner_username,
url,
caption,
caption_hashtags,
caption_mentions,
is_video,
media_url,
likes,
comments)