Skip to content
Advertisement

How to get username of Instagram account

I want to know how I can print the username of the Instagram account by the link the user will provide using python. Image attached for better understanding.

enter image description here

Advertisement

Answer

As you mentioned, the Instagram link should be something like this:

link = "https://www.instagram.com/instagram"

What you can do, is split the string using / as separator, which turns it into a list, and from there get the last value of it:

username = link.split('/')[-1]

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement