Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import sleep
- from instagram.client import InstagramAPI
- access_token = ""
- api = InstagramAPI(access_token=access_token, client_secret="")
- users=['vivyyusof', 'rnadiasabrina', 'cheeserland', 'thepinkstilettos', 'jacsafterparty', 'redmummydotcom']
- def username_to_id(username):
- """Accepts a username and returns its ID."""
- user = api.user_search(q=username, count=1)
- if username != user[0].username:
- logger.error('Username to ID failed')
- return user[0].id
- def scrape_users(username):
- recent_media, next_url = api.user_recent_media(user_id=username_to_id(username), count=20)
- for media in recent_media:
- text=media.caption.text
- tags=media.tags
- comments_count=comments.count
- likes_count=likes.count
- for user in users:
- scrape_users(user)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement