-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscrape.py
More file actions
44 lines (39 loc) · 1.43 KB
/
scrape.py
File metadata and controls
44 lines (39 loc) · 1.43 KB
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
from igramscraper.instagram import Instagram
instagram = Instagram()
data = { 'account': {}}
# authentication supported
# instagram.with_credentials(username, pwd)
# instagram.login()
# #Getting an account by id
account = instagram.get_account('covid.ai')
data['account']['id'] = account.identifier
data['account']['username'] = account.username
data['account']['Full name'] = account.full_name
data['account']['Biography'] = account.biography
data['account']['Profile pic url'] = account.get_profile_picture_url()
data['account']['Number of published posts'] = account.media_count
data['account']['Number of followers'] = account.followed_by_count
data['account']['Number of follows'] = account.follows_count
print(data)
total_likes = 0
total_comments = 0
coms = []
medias = instagram.get_medias("covid.ai", 1000)
for x in medias:
total_likes += x.likes_count
total_comments += x.comments_count
comments = instagram.get_media_comments_by_id(x.identifier, 10000)
for comment in comments['comments']:
coms.append(comment.text)
data['comments'] = coms
data['total_likes'] = total_likes
data['total_comments'] = total_comments
print(data)
# likes = instagram.get_media_likes_by_code('B-1X4J1psWX', 100)
# # or simply for printing use
# print(account)
# for like in likes['accounts']:
# print(likes)
# comments = instagram.get_media_comments_by_id('2284384429665556331', 10000)
# for comment in comments['comments']:
# print(comment.text)