mylesai commited on
Commit
cf4432a
·
verified ·
1 Parent(s): 20b2f7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -20
app.py CHANGED
@@ -69,26 +69,46 @@ def get_insta_info(df):
69
  df['Country'] = ''
70
  df['Date Joined'] = ''
71
 
72
- for index, row in df.iterrows():
73
- print(row['Username'])
74
- profile_info = scrape_instagram(row['Username'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  if profile_info: # Only populate if profile_info is not empty
77
- df.at[index, 'Bio'] = profile_info['bio']
78
- df.at[index, 'Follower Count'] = profile_info['follower_count']
79
- df.at[index, 'Following Count'] = profile_info['following_count']
80
- df.at[index, 'Bio Links'] = ', '.join(profile_info['bio_links'])
81
- df.at[index, 'Full Name'] = profile_info['full_name']
82
- df.at[index, 'Username'] = profile_info['username']
83
- df.at[index, 'Num Posts'] = profile_info['num_posts']
84
- df.at[index, 'Profile ID'] = profile_info['profile_id']
85
- df.at[index, 'Email'] = profile_info['email']
86
- df.at[index, 'Badge'] = ', '.join(profile_info['badge'])
87
- df.at[index, 'Category'] = profile_info['category']
88
- df.at[index, 'Phone Number'] = profile_info['phone_number']
89
- df.at[index, 'City Name'] = profile_info['city_name']
90
- df.at[index, 'Country'] = profile_info['country']
91
- df.at[index, 'Date Joined'] = profile_info['date_joined']
92
 
93
  return df
94
 
@@ -176,8 +196,8 @@ def get_scrape_data(csv_file, social_media):
176
  elif social_media == 'Instagram':
177
  output_df = get_insta_info(df)
178
  print(output_df.head(2))
179
- file_name = './output.csv'
180
- output_df.to_csv('./output.csv')
181
  completion_status = "Done"
182
  return completion_status, gr.DownloadButton(label='Download AI Content', value=file_name, visible=True)
183
 
 
69
  df['Country'] = ''
70
  df['Date Joined'] = ''
71
 
72
+ def get_insta_info(df):
73
+ # Add new columns to the DataFrame
74
+ df['Bio'] = ''
75
+ df['Follower Count'] = 0
76
+ df['Following Count'] = 0
77
+ df['Bio Links'] = ''
78
+ df['Full Name'] = ''
79
+ df['Username'] = ''
80
+ df['Num Posts'] = 0
81
+ df['Profile ID'] = ''
82
+ df['Email'] = ''
83
+ df['Badge'] = ''
84
+ df['Category'] = ''
85
+ df['Phone Number'] = ''
86
+ df['City Name'] = ''
87
+ df['Country'] = ''
88
+ df['Date Joined'] = ''
89
+
90
+ links = df['Links'].values
91
+ print(links)
92
+
93
+ for i in range(len(links)):
94
+ profile_info = scrape_instagram(links[i])
95
 
96
  if profile_info: # Only populate if profile_info is not empty
97
+ df.at[i, 'Bio'] = profile_info['bio']
98
+ df.at[i, 'Follower Count'] = profile_info['follower_count']
99
+ df.at[i, 'Following Count'] = profile_info['following_count']
100
+ df.at[i, 'Bio Links'] = ', '.join(profile_info['bio_links'])
101
+ df.at[i, 'Full Name'] = profile_info['full_name']
102
+ df.at[i, 'Username'] = profile_info['username']
103
+ df.at[i, 'Num Posts'] = profile_info['num_posts']
104
+ df.at[i, 'Profile ID'] = profile_info['profile_id']
105
+ df.at[i, 'Email'] = profile_info['email']
106
+ df.at[i, 'Badge'] = ', '.join(profile_info['badge'])
107
+ df.at[i, 'Category'] = profile_info['category']
108
+ df.at[i, 'Phone Number'] = profile_info['phone_number']
109
+ df.at[i, 'City Name'] = profile_info['city_name']
110
+ df.at[i, 'Country'] = profile_info['country']
111
+ df.at[i, 'Date Joined'] = profile_info['date_joined']
112
 
113
  return df
114
 
 
196
  elif social_media == 'Instagram':
197
  output_df = get_insta_info(df)
198
  print(output_df.head(2))
199
+ file_name = f'./{social_media}_output.csv'
200
+ output_df.to_csv(f'./{social_media}_output.csv')
201
  completion_status = "Done"
202
  return completion_status, gr.DownloadButton(label='Download AI Content', value=file_name, visible=True)
203