Update app.py
Browse files
app.py
CHANGED
|
@@ -69,26 +69,46 @@ def get_insta_info(df):
|
|
| 69 |
df['Country'] = ''
|
| 70 |
df['Date Joined'] = ''
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
if profile_info: # Only populate if profile_info is not empty
|
| 77 |
-
df.at[
|
| 78 |
-
df.at[
|
| 79 |
-
df.at[
|
| 80 |
-
df.at[
|
| 81 |
-
df.at[
|
| 82 |
-
df.at[
|
| 83 |
-
df.at[
|
| 84 |
-
df.at[
|
| 85 |
-
df.at[
|
| 86 |
-
df.at[
|
| 87 |
-
df.at[
|
| 88 |
-
df.at[
|
| 89 |
-
df.at[
|
| 90 |
-
df.at[
|
| 91 |
-
df.at[
|
| 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 = './
|
| 180 |
-
output_df.to_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 |
|