DEV Community

Alexandra Brugés
Alexandra Brugés

Posted on

Instagram Investigation

hello friends, I'm trying to do a social data investigation in python, I need to get the reels data, not the reel but the stats, like views, comments and publish date, I was trying to use instaloader but this code doesn't seem to work, it makes insta feel like I have been hacked. the accounts I want the info are infact public so I was wondering if you guys have an idea of how this can be avoided, or if there's a easier way to do this.

`profile = Profile.from_username(L.context, PROFILE)

Obtain metadata of the last 50 reels

reels = profile.get_reels()

Create dictionary to store reels by date

reels_by_date = {}

for reel in reels:
# Convert timestamp to datetime object
date = datetime.fromtimestamp(reel.date)

# Add reel to dictionary
if date.date() not in reels_by_date:
reels_by_date[date.date()] = [reel]
else:
reels_by_date[date.date()].append(reel)
Enter fullscreen mode Exit fullscreen mode




Print reels by date

for date, reels in reels_by_date.items():
print(f"Reels for {date}:")
for reel in reels:
print(f" - Reel {reel.shortcode} has {reel.views} views and {reel.comments} comments.")`

Top comments (0)