instaLooter
also provides an API
that can be used to extend the capabilities of instaLooter
, to fit your
needs more tightly or to integrate instaLooter
to your program.
Download 50 posts from the Dream Wife band
account to the Pictures
directory in your home folder (you better be checking
their music though):
from instalooter.looters import ProfileLooter
looter = ProfileLooter("dreamwifetheband")
looter.download('~/Pictures', media_count=50)
Create a list with all the links to picture and video files tagged with
#ramones in a file
named ramones.txt
:
def links(media, looter):
if media.get('__typename') == "GraphSidecar":
media = looter.get_post_info(media['shortcode'])
nodes = [e['node'] for e in media['edge_sidecar_to_children']['edges']]
return [n.get('video_url') or n.get('display_url') for n in nodes]
elif media['is_video']:
media = looter.get_post_info(media['shortcode'])
return [media['video_url']]
else:
return [media['display_url']]
from instalooter.looters import HashtagLooter
looter = HashtagLooter("ramones")
with open("ramones.txt", "w") as f:
for media in looter.medias():
for link in links(media, looter):
f.write("{}\n".format(link))
Obtain a subset of users that commented on some of the posts of Franz Ferdinand.
from instalooter.looters import ProfileLooter
looter = ProfileLooter("franz_ferdinand")
users = set()
for media in looter.medias():
info = looter.get_post_info(media['shortcode'])
for comment in post_info['edge_media_to_comment']['edges']:
user = comment['node']['owner']['username']
users.add(user)
from instalooter.looters import ProfileLooter
looter = ProfileLooter("mandodiaomusic")
users = set()
for media in looter.medias():
info = looter.get_post_info(media['shortcode'])
for comment in post_info['edge_media_to_tagged_user']['edges']:
user = comment['node']['user']['username']
users.add(user)
Unfortunately, this is not possible anymore as Instagram added a hash signature to prevent messing with their URLs.