Spaces:
Sleeping
Sleeping
Update app.py
#1
by
Illioa
- opened
app.py
CHANGED
@@ -39,8 +39,7 @@ async def get_channels_by_category(category_name):
|
|
39 |
response = await asession.get(category_link, headers=headers)
|
40 |
channels_list = response.html.find("#category-list-form > div.row.justify-content-center.lm-list-container > div")
|
41 |
channels_data = []
|
42 |
-
|
43 |
-
for index,channel in enumerate(channels_list):
|
44 |
channel_name = channel.find('div.font-16.text-dark.text-truncate', first=True).text
|
45 |
Tgstat_link = str(list(channel.absolute_links)[0]) +'/stat'
|
46 |
|
@@ -101,9 +100,7 @@ async def get_channels_by_category(category_name):
|
|
101 |
values['Name'] = channel_name
|
102 |
values['Tgstat_link'] = Tgstat_link
|
103 |
|
104 |
-
|
105 |
-
my_bar.progress((index + 1)/len(channels_list), text=channel_name)
|
106 |
-
my_bar.empty()
|
107 |
df = pd.DataFrame(channels_data)
|
108 |
df = df.rename(columns={'Возраст канала (Канал создан)': 'Канал создан'})
|
109 |
# df['Канал создан'] = pd.to_datetime(df['Канал создан'], format='%d.%m.%Y', errors='coerce')
|
@@ -124,6 +121,7 @@ async def get_channels_by_category(category_name):
|
|
124 |
'Пол подписчиков', 'Stories'
|
125 |
]
|
126 |
desired_column_order = [x for x in desired_column_order if x in df.columns]
|
|
|
127 |
# Reorder the columns in the DataFrame
|
128 |
df = df[desired_column_order]
|
129 |
|
@@ -131,8 +129,6 @@ async def get_channels_by_category(category_name):
|
|
131 |
df.to_csv(f'{category_name}.csv', index=False)
|
132 |
return df
|
133 |
|
134 |
-
|
135 |
-
|
136 |
def fetch_data(selected_category):
|
137 |
loop = asyncio.new_event_loop()
|
138 |
asyncio.set_event_loop(loop)
|
|
|
39 |
response = await asession.get(category_link, headers=headers)
|
40 |
channels_list = response.html.find("#category-list-form > div.row.justify-content-center.lm-list-container > div")
|
41 |
channels_data = []
|
42 |
+
for channel in tqdm(channels_list, desc=f'Fetching Channels for {category_name}', ncols=100):
|
|
|
43 |
channel_name = channel.find('div.font-16.text-dark.text-truncate', first=True).text
|
44 |
Tgstat_link = str(list(channel.absolute_links)[0]) +'/stat'
|
45 |
|
|
|
100 |
values['Name'] = channel_name
|
101 |
values['Tgstat_link'] = Tgstat_link
|
102 |
|
103 |
+
channels_data.append(values)
|
|
|
|
|
104 |
df = pd.DataFrame(channels_data)
|
105 |
df = df.rename(columns={'Возраст канала (Канал создан)': 'Канал создан'})
|
106 |
# df['Канал создан'] = pd.to_datetime(df['Канал создан'], format='%d.%m.%Y', errors='coerce')
|
|
|
121 |
'Пол подписчиков', 'Stories'
|
122 |
]
|
123 |
desired_column_order = [x for x in desired_column_order if x in df.columns]
|
124 |
+
|
125 |
# Reorder the columns in the DataFrame
|
126 |
df = df[desired_column_order]
|
127 |
|
|
|
129 |
df.to_csv(f'{category_name}.csv', index=False)
|
130 |
return df
|
131 |
|
|
|
|
|
132 |
def fetch_data(selected_category):
|
133 |
loop = asyncio.new_event_loop()
|
134 |
asyncio.set_event_loop(loop)
|